/* ================================================================
   YLY Mobile Responsive CSS - mobile.css
   تحسينات كاملة للتوافقية مع الهواتف المحمولة (< 768px)
   ================================================================ */

/* ─── 1. Base: منع الـ Overflow الأفقي (CRITICAL) ───────────────── */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
}

body {
  overflow-x: hidden;
  max-width: 100vw;
}

img, svg, video {
  max-width: 100%;
  height: auto;
}

/* ─── Language Mutual Exclusion ──────────────────────────────────── */
html[lang="ar"] .lang-en,
html[dir="rtl"] .lang-en,
body:not(.lang-english) .lang-en {
  display: none !important;
}

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

/* ─── 2. Container ───────────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding-inline: clamp(1rem, 4vw, 2rem);
}

/* ─── 3. Navbar: تحسينات إضافية (الأساسي في Navbar.tsx) ────────── */
/* Theme & Lang toggles على الديسكتوب */
.theme-toggle-btn,
.lang-toggle {
  min-width: 38px;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border-radius: 8px;
  transition: background 0.2s ease;
  cursor: pointer;
  border: none;
  background: transparent;
}

.theme-toggle-btn:hover,
.lang-toggle:hover {
  background: rgba(255, 255, 255, 0.08);
}

/* ─── 4. Hero Section & Mobile UI Optimization ───────────────────── */
/* Strictly isolated to Mobile screens: Zero side-effects on Tablets & Desktop */
@media (max-width: 767px) {
  :root {
    --mobile-pad-x: 20px;
    --mobile-text-sub: #cbd5e1;
    --mobile-primary-blue: #2563eb;
    --mobile-accent-cyan: #38bdf8;
    --mobile-navy-bg: #040916;
  }

  /* 7) Unified Arabic Font with font-display: swap on mobile */
  body, h1, h2, h3, h4, h5, h6, p, button, a, span, input, select, textarea {
    font-family: 'Cairo', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
  }

  /* 1) Prevent any horizontal scroll on mobile */
  html, body {
    overflow-x: hidden !important;
    max-width: 100vw !important;
    position: relative !important;
  }

  /* 2) Floating Quick Action Button (+) - Hidden on mobile so it never covers titles */
  #fab-container,
  #fab-main {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
    opacity: 0 !important;
  }

  /* 2) Header / Navbar on Mobile: Small Logo + Brand Title + Hamburger */
  .navbar-floating {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    flex-direction: row !important;
    width: calc(100% - 24px) !important;
    height: 54px !important;
    padding-inline: 12px 10px !important;
    box-sizing: border-box !important;
  }

  .navbar-brand-link {
    display: inline-flex !important;
    align-items: center !important;
    gap: 10px !important;
    text-decoration: none !important;
    flex-shrink: 0 !important;
  }

  /* Circular logo inside navbar on mobile (38px, with 10px gap next to text) */
  .navbar-logo-wrap {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 38px !important;
    height: 38px !important;
    min-width: 38px !important;
    min-height: 38px !important;
    border-radius: 50% !important;
    overflow: hidden !important;
    flex-shrink: 0 !important;
    border: 1.5px solid rgba(56, 189, 248, 0.45) !important;
    background: rgba(10, 22, 40, 0.7) !important;
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.25) !important;
  }

  .navbar-logo-img {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    border-radius: 50% !important;
    padding: 2px !important;
  }

  .navbar-brand-title {
    font-size: clamp(0.88rem, 2.7vw, 1rem) !important;
    font-weight: 800 !important;
    color: var(--nav-text) !important;
    white-space: nowrap !important;
    overflow: visible !important;
    text-overflow: clip !important;
    letter-spacing: -0.2px !important;
  }

  .navbar-brand-subtitle {
    display: none !important;
  }

  @media (max-width: 359px) {
    .navbar-title-full {
      display: none !important;
    }
    .navbar-title-short {
      display: inline-block !important;
      font-size: 1.05rem !important;
      font-weight: 900 !important;
      letter-spacing: 1px !important;
      color: var(--mobile-accent-cyan) !important;
    }
  }

  .navbar-toggle-btn {
    min-width: 44px !important;
    min-height: 44px !important;
    width: 44px !important;
    height: 44px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    margin: 0 !important;
    flex-shrink: 0 !important;
  }

  /* 1) Hero Container: 28px clearance below navbar (total padding-top = 92px) */
  .hero {
    min-height: 100svh !important;
    height: auto !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-start !important;
    align-items: center !important;
    padding-top: calc(env(safe-area-inset-top, 0px) + 92px) !important;
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px)) !important;
    padding-inline: var(--mobile-pad-x) !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
    overflow-y: visible !important;
    max-width: 100% !important;
  }

  .hero-inner {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: flex-start !important;
    text-align: center !important;
    margin: 0 auto !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    gap: 0 !important;
    overflow: visible !important;
  }

  /* 1) Large Hero Logo: Downward clearance + unclipped glow */
  .hero-logo-wrap {
    position: relative !important;
    width: 120px !important;
    height: 120px !important;
    margin: 0 auto 0.75rem auto !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    filter: drop-shadow(0 0 18px rgba(56, 189, 248, 0.45)) !important;
    transition: transform 0.25s ease !important;
    overflow: visible !important;
  }

  .hero-logo-ring {
    position: absolute !important;
    inset: -7px !important;
    border-radius: 50% !important;
    border: 2px solid rgba(56, 189, 248, 0.65) !important;
    box-shadow: 0 0 14px rgba(56, 189, 248, 0.3), inset 0 0 12px rgba(37, 99, 235, 0.25) !important;
    overflow: visible !important;
  }

  .hero-logo-ring::before {
    top: -5px !important;
    width: 9px !important;
    height: 9px !important;
    background: var(--mobile-accent-cyan) !important;
    box-shadow: 0 0 8px var(--mobile-accent-cyan) !important;
  }

  .hero-logo-wrap .hero-logo-img,
  .hero-logo-img,
  .hero-grand-logo-img {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    object-fit: contain !important;
    border-radius: 50% !important;
    border: 2px solid rgba(255, 255, 255, 0.35) !important;
    background: rgba(10, 22, 40, 0.85) !important;
    padding: 3px !important;
    box-sizing: border-box !important;
  }

  /* Accreditation Badge (رقم الإشهار 1173 لسنة 2025) */
  .hero-reg-tag {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-direction: row !important;
    gap: 8px !important;
    direction: rtl !important;
    background: rgba(13, 26, 58, 0.92) !important;
    border: 1.5px solid rgba(56, 189, 248, 0.45) !important;
    padding: 5px 16px !important;
    border-radius: 9999px !important;
    backdrop-filter: blur(14px) !important;
    -webkit-backdrop-filter: blur(14px) !important;
    box-shadow: 0 4px 16px rgba(6, 182, 212, 0.22) !important;
    margin: 0 auto 0.25rem auto !important;
  }

  .hero-ministry-title {
    font-size: clamp(0.95rem, 3.8vw, 1.3rem) !important;
    font-weight: 700 !important;
    line-height: 1.15 !important;
    margin: 0 auto 6px auto !important;
    white-space: nowrap !important;
  }

  .hero-reg-tag svg {
    width: 19px !important;
    height: 19px !important;
    min-width: 19px !important;
    color: var(--mobile-accent-cyan) !important;
    filter: drop-shadow(0 0 6px rgba(56, 189, 248, 0.6)) !important;
    flex-shrink: 0 !important;
  }

  .hero-reg-tag .lang-ar,
  .hero-reg-tag .lang-en {
    color: #f8fafc !important;
    font-size: 0.92rem !important;
    font-weight: 700 !important;
    letter-spacing: 0.3px !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
    direction: rtl !important;
  }

  .hero-reg-num {
    color: var(--mobile-accent-cyan) !important;
    font-weight: 900 !important;
    font-size: 0.96rem !important;
    background: rgba(56, 189, 248, 0.2) !important;
    padding: 2px 7px !important;
    border-radius: 6px !important;
    border: 1px solid rgba(56, 189, 248, 0.35) !important;
  }

  /* Main Title */
  .hero-title-new {
    font-size: clamp(1.85rem, 7.2vw, 2.5rem) !important;
    line-height: 1.28 !important;
    text-wrap: balance !important;
    overflow-wrap: break-word !important;
    word-break: normal !important;
    letter-spacing: -0.5px !important;
    color: #ffffff !important;
    text-shadow: 0 3px 24px rgba(0, 0, 0, 0.6) !important;
    margin: 0 auto 0.65rem auto !important;
    padding-inline: 4px !important;
    max-width: 100% !important;
  }

  .hero-title-phrase {
    display: inline !important;
  }

  .hero-yly-word {
    display: inline-block !important;
    direction: ltr !important;
    unicode-bidi: isolate !important;
    font-weight: 900 !important;
    margin-inline-start: 0.35rem !important;
    color: #ffffff !important;
  }

  /* Subtitle / Description */
  .hero-subtitle-new {
    font-size: clamp(0.88rem, 3.4vw, 1rem) !important;
    color: var(--mobile-text-sub) !important;
    line-height: 1.6 !important;
    text-wrap: balance !important;
    max-width: 100% !important;
    padding-inline: 4px !important;
    margin: 0 auto 0.95rem auto !important;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3) !important;
  }

  /* CTA Buttons Group: Compact & Perfectly Stacked Above the Fold */
  .hero-btns {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    width: 100% !important;
    max-width: 380px !important;
    gap: 10px !important;
    margin: 0 auto !important;
    padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px)) !important;
    box-sizing: border-box !important;
  }

  /* Primary "انضم الآن" Button */
  .hero-btn-join {
    width: 100% !important;
    min-height: 52px !important;
    height: 52px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 10px !important;
    background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 52%, #0ea5e9 100%) !important;
    color: #ffffff !important;
    font-size: 1.05rem !important;
    font-weight: 800 !important;
    border-radius: 9999px !important;
    border: 1px solid rgba(255, 255, 255, 0.25) !important;
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.38) !important;
    cursor: pointer !important;
    text-decoration: none !important;
    box-sizing: border-box !important;
    transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease !important;
  }

  .hero-btn-join:active,
  .hero-btn-join:focus-visible {
    transform: scale(0.98) !important;
    box-shadow: 0 2px 10px rgba(37, 99, 235, 0.6) !important;
    filter: brightness(1.12) !important;
    outline: 2px solid var(--mobile-accent-cyan) !important;
    outline-offset: 2px !important;
  }

  /* Secondary "تعرّف علينا" Button: Centered text & clean padding */
  .hero-btn-explore {
    width: 100% !important;
    min-height: 48px !important;
    height: 48px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    padding: 0 20px !important;
    background: rgba(255, 255, 255, 0.06) !important;
    border: 1px solid rgba(255, 255, 255, 0.18) !important;
    border-radius: 9999px !important;
    color: #f1f5f9 !important;
    font-size: 0.95rem !important;
    font-weight: 700 !important;
    text-align: center !important;
    text-decoration: none !important;
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2) !important;
    box-sizing: border-box !important;
    transition: transform 0.15s ease, background 0.15s ease !important;
  }

  .hero-btn-explore:active,
  .hero-btn-explore:focus-visible {
    transform: scale(0.98) !important;
    background: rgba(255, 255, 255, 0.12) !important;
    outline: 2px solid rgba(255, 255, 255, 0.4) !important;
    outline-offset: 2px !important;
  }

  /* 3) Suppress decorative shapes & remove scroll cue completely */
  .hero-shapes {
    display: none !important;
  }

  .hero-scroll-cue,
  #hero-scroll-cue {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
    opacity: 0 !important;
  }
}

/* ─── 5. Stats Bar ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  .stats-bar {
    padding: 1.5rem 0;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0;
  }

  .stat-item {
    padding: 1rem 0.75rem;
    border: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  }

  .stat-item:nth-child(odd) {
    border-right: 1px solid rgba(255, 255, 255, 0.06);
  }

  .stat-number-new {
    font-size: 1.9rem;
  }

  .stat-label-new {
    font-size: 0.78rem;
  }

  .stat-icon-wrap {
    width: 38px;
    height: 38px;
  }
}

/* ─── 6. About Section ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .about-section-new {
    padding: 4rem 0;
  }

  .about-inner {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .about-heading {
    font-size: clamp(1.6rem, 6vw, 2.2rem);
  }

  .about-badge-float {
    display: none; /* إخفاء الشارات الطافية على الموبايل */
  }

  .about-photo-grid {
    grid-template-columns: 1fr;
  }

  .about-photo-card:first-child {
    grid-column: span 1;
    aspect-ratio: 16 / 7;
  }
}

/* ─── 7. Timeline ───────────────────────────────────────────────── */
@media (max-width: 768px) {
  .timeline-section {
    padding: 3.5rem 0;
  }

  .timeline-section::before {
    display: none; /* إخفاء العنصر الزخرفي الكبير */
  }

  .timeline-line {
    display: none;
  }

  .timeline-item {
    flex-direction: column !important;
    text-align: start !important;
    gap: 1rem;
    margin-bottom: 1.5rem;
  }

  .timeline-content-wrap {
    padding: 1.2rem 1.4rem;
  }

  .timeline-title {
    font-size: 1.05rem;
  }

  .timeline-desc {
    font-size: 0.88rem;
  }
}

/* ─── 8. Achievements ───────────────────────────────────────────── */
@media (max-width: 768px) {
  .achievements-section {
    padding: 3.5rem 0;
  }

  .achievements-grid {
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
  }

  .achievement-card {
    padding: 1.25rem;
  }

  .achievement-num {
    font-size: 2rem;
  }
}

@media (max-width: 400px) {
  .achievements-grid {
    grid-template-columns: 1fr;
  }
}

/* ─── 9. Videos Section ─────────────────────────────────────────── */
@media (max-width: 768px) {
  .videos-section {
    padding: 3.5rem 0;
  }

  .videos-grid {
    grid-template-columns: 1fr;
  }

  .video-card-main {
    grid-row: span 1;
  }
}

/* ─── 10. Alumni Section ────────────────────────────────────────── */
@media (max-width: 768px) {
  .alumni-section {
    padding: 4rem 0;
  }

  .alumni-grid {
    grid-template-columns: 1fr;
  }
}

/* ─── 11. Section Headings (shared) ────────────────────────────── */
@media (max-width: 768px) {
  .section-badge,
  .about-badge-new {
    font-size: 0.78rem;
    padding: 5px 14px;
  }

  .section-title {
    font-size: clamp(1.5rem, 6vw, 2.2rem) !important;
  }

  .section-subtitle {
    font-size: 0.9rem !important;
  }
}

/* ─── 12. Join Modal ────────────────────────────────────────────── */
@media (max-width: 768px) {
  .join-modal {
    padding: 1.5rem 1.25rem;
    margin: 1rem;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: 20px;
  }

  .join-modal-title {
    font-size: 1.3rem;
  }

  .join-form-input,
  .join-form-select {
    font-size: 1rem; /* منع التكبير التلقائي على iOS */
  }

  .join-submit-btn {
    min-height: 52px;
    font-size: 1rem;
  }
}

/* ─── 13. Intro Screen (Lightweight mobile version) ─────────────── */
@media (max-width: 600px) {
  /* تقليل حجم شاشة الانترو */
  .intro-stage {
    width: clamp(160px, 55vw, 240px);
    height: clamp(160px, 55vw, 240px);
  }

  /* تقليل شدة الـ backdrop-filter لتحسين الأداء */
  .fx-glow {
    display: none;
  }

  /* زر التخطي: أكبر وأسهل للضغط */
  #intro-skip {
    padding: 0.65rem 2rem;
    font-size: 0.95rem;
    min-height: 44px;
    bottom: 1.5rem;
  }
}

/* ─── 14. Performance: تعطيل الأنيميشن الثقيلة على الموبايل ──── */
@media (max-width: 768px) and (prefers-reduced-motion: no-preference) {
  /* تقليل حركة الأشكال الطافية */
  .hero-shape {
    animation-duration: 15s;
    opacity: 0.015;
  }

  /* تقليل حركة spin-slow على الشعار */
  .hero-logo-ring {
    animation-duration: 30s;
  }
}

/* إيقاف الأنيميشن تماماً لمن يفضل ذلك */
@media (prefers-reduced-motion: reduce) {
  .hero-shape,
  .hero-logo-ring,
  .hero-pill-dot,
  .scroll-mouse-ball,
  .timeline-item {
    animation: none !important;
    transition: none !important;
  }

  .timeline-item {
    opacity: 1 !important;
    transform: none !important;
  }
}

/* ─── 15. Touch feedback improvements ───────────────────────────── */
@media (hover: none) and (pointer: coarse) {
  /* إزالة hover effects على الشاشات اللمسية */
  .achievement-card:hover,
  .alumni-card:hover,
  .about-vision-card:hover,
  .timeline-content-wrap:hover,
  .about-photo-card:hover {
    transform: none;
  }

  /* تطبيق تأثير ضغط بدلاً من hover */
  .hero-btn-join:active {
    transform: scale(0.97);
  }

  .hero-btn-explore:active {
    transform: scale(0.97);
  }

  /* أحجام أزرار لمسية مناسبة */
  .hero-dot {
    min-width: 14px;
    min-height: 14px;
  }
}

/* ─── 16. UserMenu dropdown on mobile ───────────────────────────── */
@media (max-width: 768px) {
  .user-menu-dropdown {
    right: -0.5rem !important;
    left: auto;
    max-width: calc(100vw - 2rem);
    min-width: 220px;
  }

  .user-menu-btn {
    min-width: 44px;
    min-height: 44px;
  }

  /* Collapsed icon-only strip */
  .user-menu-dropdown.user-menu-collapsed {
    width: 4rem;
    min-width: 4rem;
  }
}

/* ─── 17. News Page ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .news-grid,
  .events-grid {
    grid-template-columns: 1fr !important;
  }

  .news-hero {
    padding: 5rem 0 3rem;
  }

  .news-card,
  .event-card {
    border-radius: 14px;
  }
}

/* ─── 18. Board Page ────────────────────────────────────────────── */
@media (max-width: 768px) {
  .board-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 1rem;
  }

  .board-card-img {
    height: 140px !important;
  }
}

@media (max-width: 400px) {
  .board-grid {
    grid-template-columns: 1fr !important;
  }
}

/* ─── 19. Dashboard Page ────────────────────────────────────────── */
@media (max-width: 768px) {
  .dashboard-stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  .dashboard-sidebar {
    position: fixed;
    z-index: 1000;
    transform: translateX(100%);
    transition: transform 0.3s ease;
  }

  .dashboard-sidebar.open {
    transform: translateX(0);
  }
}

/* ─── 20. Footer ────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .footer-grid {
    grid-template-columns: 1fr !important;
    gap: 2rem !important;
  }

  .footer-brand {
    text-align: center;
  }
}

/* ─── 21. Prevent iOS font zoom on inputs ───────────────────────── */
@supports (-webkit-touch-callout: none) {
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="tel"],
  select,
  textarea {
    font-size: 16px !important;
  }
}
