/* ============================================================
   MEGA AI — custom styles (extracted from index.html)
   ============================================================ */

:root { color-scheme: dark; }
html, body { background-color: #050505; }
body {
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  /* Dark-theme ambience: layered neon glows over pure black */
  background-image:
    radial-gradient(55% 40% at 15% 0%, rgba(136, 15, 166, 0.14) 0%, transparent 70%),
    radial-gradient(50% 35% at 85% 10%, rgba(56, 189, 248, 0.10) 0%, transparent 70%),
    radial-gradient(60% 45% at 50% 100%, rgba(136, 15, 166, 0.08) 0%, transparent 75%);
  background-attachment: fixed;
}

/* Glassmorphism helper */
.glass {
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.07) 0%, rgba(255, 255, 255, 0.03) 100%);
  backdrop-filter: blur(8px) saturate(130%);
  -webkit-backdrop-filter: blur(8px) saturate(130%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 8px 24px -12px rgba(0, 0, 0, 0.5);
}
.glass-strong {
  background: linear-gradient(170deg, rgba(20, 22, 28, 0.65) 0%, rgba(10, 11, 14, 0.55) 100%);
  backdrop-filter: blur(10px) saturate(140%);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 16px 40px -16px rgba(0, 0, 0, 0.6);
}

/* Gradient text */
.text-gradient {
  background: linear-gradient(100deg, #ffffff 0%, #e3b8f2 35%, #b15cc9 60%, #880FA6 78%, #38bdf8 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 14px rgba(136, 15, 166, 0.25)) drop-shadow(0 0 24px rgba(56, 189, 248, 0.1));
}

/* Reveal-on-scroll */
.reveal { opacity: 0; transform: translateY(24px); transition: opacity .7s ease, transform .7s cubic-bezier(.2,.8,.2,1); }
.reveal.is-visible { opacity: 1; transform: none; }

/* Subtle grid overlay */
.bg-grid {
  background-image:
    linear-gradient(rgba(255,255,255,0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.018) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(70% 60% at 50% 30%, #000 0%, transparent 80%);
  -webkit-mask-image: radial-gradient(70% 60% at 50% 30%, #000 0%, transparent 80%);
}

/* Code rain canvas sits behind content */
#code-rain { position: fixed; inset: 0; z-index: 0; pointer-events: none; }

/* Digital particle network sits behind content, above the code rain */
#particle-field { position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: 0.8; }

/* Subtle CRT scanlines for a digital/creative feel */
.scanlines {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: repeating-linear-gradient(
    0deg,
    rgba(255, 255, 255, 0.018) 0px,
    rgba(255, 255, 255, 0.018) 1px,
    transparent 1px,
    transparent 3px
  );
  opacity: 0.4;
}

/* Custom scrollbar (dark theme) */
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: #050505; }
::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #3b2350 0%, #1f2937 100%);
  border-radius: 8px;
  border: 2px solid #050505;
}
::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #880FA6 0%, #374151 100%);
}

/* Keyboard focus: visible neon ring on the black background */
:focus-visible {
  outline: 2px solid rgba(136, 15, 166, 0.8);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(136, 15, 166, 0.25);
}

/* Card hover: soft neon lift on the black background */
article.glass:hover,
.glass.rounded-2xl:hover {
  border-color: rgba(136, 15, 166, 0.35);
}

/* Section dividers: faint neon hairline between sections */
main > section + section {
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

/* Powered-by marquee: circular ring — first name meets last name seamlessly */
.marquee-ring {
  overflow: hidden;
  position: relative;
}
.marquee-track {
  display: flex;
  width: max-content;
  direction: ltr; /* keep the loop direction stable even when the page is RTL (Arabic) */
  animation: marquee-scroll 32s linear infinite;
}
.marquee-track:hover { animation-play-state: paused; }
@keyframes marquee-scroll {
  from { transform: translateX(0); }
  /* -50% lands 0.5 gap short of the first copy's true width (25 gaps total vs 13 per copy),
     so add half the gap (gap-x-10 = 2.5rem) to make the loop seam perfectly seamless */
  to   { transform: translateX(calc(-50% - 1.25rem)); }
}

/* Unified typography: same font family and size in both languages.
   Inter renders Latin text; Tajawal is only a fallback for Arabic glyphs, so
   the visual size and style stay identical when switching AR / EN. */
body { font-family: 'Inter', 'Tajawal', ui-sans-serif, system-ui, sans-serif; }
html[lang="ar"] body { font-family: 'Inter', 'Tajawal', ui-sans-serif, system-ui, sans-serif; }

/* Brand name keeps the same font and size in both languages */
.brand-name { font-family: 'Inter', 'Tajawal', ui-sans-serif, system-ui, sans-serif !important; font-size: 1.125rem !important; }

@media (prefers-reduced-motion: reduce) {
  .reveal { transition: none; opacity: 1; transform: none; }
  .marquee-track { animation: none; }
}

/* ---------- Responsive: PC / Tablet / Mobile — no overlap ---------- */
html { scroll-padding-top: 96px; } /* anchors land below the fixed nav */
html, body { overflow-x: hidden; } /* never allow horizontal scroll */

/* Nav bar: brand name may shrink, actions never get squashed */
#nav a[href="#top"] { min-width: 0; }
#nav .brand-name {
  flex-shrink: 0;
  white-space: nowrap;
}
#nav .nav-actions { flex-shrink: 0; }

/* Small phones (<= 480px) */
@media (max-width: 480px) {
  .brand-name { font-size: 1rem !important; }
  #nav .glass-strong { padding-left: 0.75rem; padding-right: 0.75rem; }
  #lang-en, #lang-ar { padding-left: 0.5rem; padding-right: 0.5rem; }
  #menu-btn { width: 2.5rem; height: 2.5rem; }
  .hero-visual pre { font-size: 11px; }

/* Hero screenshot carousel — Fade In / Fade Out between slides */
#hero-carousel-track img {
  transition: opacity .7s cubic-bezier(.2, .8, .2, 1);
  will-change: opacity;
  border-radius: 1.5rem; /* rounded corners on the images themselves */
}
@media (prefers-reduced-motion: reduce) {
  #hero-carousel-track img { transition: none; }
}
}

/* 3D interactive card: the WHOLE card (image + rounded corners + dots) tilts toward the cursor (transform set from main.js) */
#hero-carousel { perspective: 1200px; }
#hero-card {
  transform-style: preserve-3d;
  transform-origin: center center;
  transition: transform .18s ease-out;
  will-change: transform;
  box-shadow: 0 0 28px rgba(136, 15, 166, 0.45), 0 0 56px rgba(56, 189, 248, 0.22);
}

/* Animated neon ring (blue + purple) around the card */
@property --neon-angle { syntax: '<angle>'; initial-value: 0deg; inherits: false; }
.hero-neon-border {
  position: absolute;
  inset: -4px;
  z-index: 0;
  border-radius: calc(1.5rem + 4px);
  background: conic-gradient(from var(--neon-angle, 0deg),
    #38bdf8 0deg, #880FA6 90deg, #38bdf8 180deg, #880FA6 270deg, #38bdf8 360deg);
  filter: blur(16px);
  opacity: 0.85;
  animation: neon-spin 5s linear infinite, neon-pulse 3s ease-in-out infinite;
  pointer-events: none;
}
@keyframes neon-spin { to { --neon-angle: 360deg; } }
@keyframes neon-pulse {
  0%, 100% { opacity: 0.6; filter: blur(14px); }
  50%      { opacity: 1;   filter: blur(22px); }
}

/* Light glare that follows the cursor (position set via CSS vars from main.js) */
.hero-3d-glare {
  background: radial-gradient(420px circle at var(--glare-x, 50%) var(--glare-y, 50%),
    rgba(255, 255, 255, 0.14) 0%, rgba(255, 255, 255, 0.05) 35%, transparent 60%);
  opacity: 0;
  transition: opacity .35s ease;
}
#hero-carousel:hover .hero-3d-glare { opacity: 1; }
@media (prefers-reduced-motion: reduce) {
  #hero-card { transition: none; }
  .hero-3d-glare { display: none; }
  .hero-neon-border { animation: none; }
}

/* Very small phones (<= 360px): keep brand text visible by shrinking it */
@media (max-width: 360px) {
  #nav a[href="#top"] { gap: 0.5rem; }
  #nav a[href="#top"] img { width: 1.75rem; height: 1.75rem; }
  #nav .brand-name { font-size: 0.875rem !important; }
}

/* ---------- Crafted-by badge (footer signature) ---------- */
.crafted-badge {
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(8px) saturate(120%);
  -webkit-backdrop-filter: blur(8px) saturate(120%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 0 24px rgba(136, 15, 166, 0.25), 0 0 40px rgba(56, 189, 248, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  overflow: hidden;
  transition: transform .35s cubic-bezier(.2,.8,.2,1), box-shadow .35s ease;
}
.crafted-badge::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 35%, rgba(255,255,255,0.18) 50%, transparent 65%);
  transform: translateX(-120%);
  animation: crafted-shine 4.5s ease-in-out infinite;
  pointer-events: none;
}
.crafted-badge:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 32px rgba(136, 15, 166, 0.4), 0 0 56px rgba(56, 189, 248, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}
@keyframes crafted-shine {
  0%, 55% { transform: translateX(-120%); }
  75%, 100% { transform: translateX(120%); }
}
@media (prefers-reduced-motion: reduce) {
  .crafted-badge::after { animation: none; }
  .crafted-badge { transition: none; }
}
