:root{
  /* ===== Red Dark Theme ===== */
  --bg:#070204;
  --card1:#120406;
  --card2:#0c0305;
  --line:#2a0b10;

  --txt:#fff3f4;
  --muted:rgba(255,243,244,.72);

  --main:#b91c1c;   /* deep red */
  --red2:#ef4444;   /* brighter red */

  --ok:#22c55e;
  --bad:#ef4444;

  /* ✅ Visitors green */
  --green:#22c55e;
  --green2:#86efac;
}

*{box-sizing:border-box;font-family:Inter,system-ui,-apple-system,Segoe UI,Roboto,Arial}
html,body{height:100%}

body{
  margin:0;
  min-height:100vh;
  color:var(--txt);

  background:
    radial-gradient(circle at 85% 15%, rgba(239,68,68,.22), transparent 48%),
    radial-gradient(circle at 15% 85%, rgba(185,28,28,.18), transparent 52%),
    radial-gradient(circle at 70% 70%, rgba(239,68,68,.10), transparent 55%),
    var(--bg);

  overflow-x:hidden;
}

/* ===== Snow / Drops overlay (CSS فقط) ===== */
/* خليها تحت المودالات */
body::before,
body::after{
  content:"";
  position:fixed;
  inset:0;
  pointer-events:none;
  z-index:8;
  opacity:.9;
}

body::before{
  background-image:
    radial-gradient(circle, rgba(255,255,255,.70) 1px, transparent 2px),
    radial-gradient(circle, rgba(255,255,255,.45) 1px, transparent 2px),
    radial-gradient(circle, rgba(255,255,255,.35) 1px, transparent 2px);
  background-size: 280px 280px, 420px 420px, 620px 620px;
  background-position: 0 0, 120px -80px, -160px -140px;
  filter: drop-shadow(0 0 6px rgba(255,255,255,.06));
  animation: snowFall 14s linear infinite;
}

body::after{
  background-image:
    radial-gradient(circle, rgba(255,255,255,.30) 1.3px, transparent 2.6px),
    radial-gradient(circle, rgba(255,255,255,.18) 1.3px, transparent 2.6px);
  background-size: 520px 520px, 820px 820px;
  background-position: 60px -140px, -220px -260px;
  opacity:.55;
  animation: snowFall2 20s linear infinite;
}

@keyframes snowFall{
  from { transform: translateY(-120px); }
  to   { transform: translateY(980px); }
}
@keyframes snowFall2{
  from { transform: translateY(-220px); }
  to   { transform: translateY(1100px); }
}

/* ===== HERO ===== */
.hero{
  text-align:center;
  padding:110px 20px 70px;
}

.badge{
  display:inline-flex;
  align-items:center;
  gap:10px;
  padding:10px 16px;
  border-radius:999px;
  background:rgba(20,6,8,.72);
  border:1px solid rgba(42,11,16,.95);
  color:#ffd1d1;
  box-shadow:
    0 0 0 1px rgba(255,255,255,.02) inset,
    0 18px 55px rgba(239,68,68,.06);
}

/* ✅ Visitors badge (Green glow) */
.visitors-badge{
  background:rgba(6,20,10,.60);
  border:1px solid rgba(34,197,94,.45);
  color:rgba(220,255,235,.95);
  box-shadow:
    0 0 0 1px rgba(255,255,255,.02) inset,
    0 18px 55px rgba(34,197,94,.12),
    0 0 60px rgba(34,197,94,.10);
}

.visitors-badge .dot{
  width:10px;
  height:10px;
  border-radius:50%;
  background:radial-gradient(circle at 30% 30%, var(--green2), var(--green));
  box-shadow: 0 0 18px rgba(34,197,94,.55);
  display:inline-block;
}

#visitorsCount{
  font-weight:900;
  color:rgba(240,255,246,.98);
  text-shadow: 0 0 18px rgba(34,197,94,.30);
}

.hero h1{
  font-size:64px;
  margin:18px 0 10px;
  letter-spacing:-0.6px;
}

.hero h1 span{
  background:linear-gradient(90deg, var(--red2), var(--main));
  -webkit-background-clip:text;
  color:transparent;
}

.role{
  margin:0;
  font-size:22px;
  color:rgba(255,243,244,.86);
}

.desc{
  margin:14px auto 0;
  max-width:760px;
  color:rgba(255,243,244,.62);
  line-height:1.8;
  font-size:14px;
}

/* ===== Buttons ===== */
.buttons{
  margin-top:30px;
  display:flex;
  gap:14px;
  justify-content:center;
  flex-wrap:wrap;
}

.btn{
  cursor:pointer;
  user-select:none;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:14px 26px;
  border-radius:16px;
  text-decoration:none;
  border:1px solid rgba(42,11,16,.95);
  background:rgba(18,4,6,.62);
  color:var(--txt);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease, filter .18s ease;
}

.btn.primary{
  background:linear-gradient(90deg, rgba(239,68,68,.35), rgba(185,28,28,.95));
  border-color: rgba(239,68,68,.55);
  box-shadow: 0 14px 45px rgba(185,28,28,.20);
}

.btn.ghost{
  background:rgba(18,4,6,.55);
}

.btn:hover{
  transform: translateY(-2px);
  border-color: rgba(239,68,68,.65);
  box-shadow:
    0 18px 55px rgba(239,68,68,.14),
    0 18px 65px rgba(185,28,28,.18);
  filter: brightness(1.07);
}
.btn:active{ transform: translateY(0); }

/* ===== PROJECTS ===== */
.projects{
  padding:60px 40px 90px;
  text-align:center;
}

.projects h2{
  font-size:44px;
  margin:0;
}

.projects h2 span{
  background:linear-gradient(90deg, var(--red2), var(--main));
  -webkit-background-clip:text;
  color:transparent;
}

.subtitle{
  margin:10px 0 0;
  color:rgba(255,243,244,.65);
}

/* ===== GRID + CARDS ===== */
.grid{
  margin:48px auto 0;
  max-width:1300px;
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(250px,1fr));
  gap:20px;
  padding:0 6px;
}

.card{
  position:relative;
  background:linear-gradient(180deg,var(--card1),var(--card2));
  border:1px solid rgba(42,11,16,.95);
  border-radius:22px;
  overflow:hidden;
  text-align:left;
  transform: translateY(0);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.card::before{
  content:"";
  position:absolute;
  inset:-2px;
  background:
    radial-gradient(circle at 20% 10%, rgba(239,68,68,.18), transparent 42%),
    radial-gradient(circle at 80% 30%, rgba(185,28,28,.22), transparent 48%);
  opacity:0;
  transition: opacity .18s ease;
  pointer-events:none;
}

.card:hover{
  transform: translateY(-6px);
  border-color: rgba(239,68,68,.55);
  box-shadow:
    0 22px 66px rgba(239,68,68,.16),
    0 18px 55px rgba(185,28,28,.14);
}
.card:hover::before{ opacity:1; }

/* الصورة ثابتة (16:9) */
.thumb{
  width:100%;
  aspect-ratio: 16 / 9;
  background:rgba(12,3,5,.8);
  overflow:hidden;
  cursor:pointer;
}
.thumb img{
  width:100%;
  height:100%;
  display:block;
  object-fit:cover;
  transform: scale(1);
  transition: transform .28s ease, filter .28s ease;
  filter: saturate(1.02) contrast(1.05);
}
.card:hover .thumb img{
  transform: scale(1.06);
  filter: saturate(1.07) contrast(1.08);
}

.card .c{
  padding:16px 16px 18px;
  position:relative;
}

.card h3{
  margin:0 0 8px;
  font-size:18px;
  color:rgba(255,243,244,.96);
}

.card p{
  margin:0;
  font-size:14px;
  color:rgba(255,243,244,.72);
  line-height:1.65;
  min-height:44px;
}

/* ✅ زر Download الحقيقي (downloadBtn) — نفس ستايل Explore */
.downloadBtn{
  cursor:pointer;
  user-select:none;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  margin-top:14px;
  padding:14px 22px;
  border-radius:16px;
  border:1px solid rgba(239,68,68,.55);
  background:linear-gradient(90deg, rgba(239,68,68,.35), rgba(185,28,28,.95));
  color:var(--txt);
  font-weight:700;
  letter-spacing:.2px;
  box-shadow: 0 14px 45px rgba(185,28,28,.20);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease, filter .18s ease;
}

.downloadBtn:hover{
  transform: translateY(-2px);
  border-color: rgba(239,68,68,.70);
  box-shadow:
    0 18px 55px rgba(239,68,68,.14),
    0 18px 65px rgba(185,28,28,.18);
  filter: brightness(1.08);
}
.downloadBtn:active{ transform: translateY(0); }

/* ===== Focus styles ===== */
a,button,input{ outline:none; }
a:focus-visible,button:focus-visible,input:focus-visible{
  box-shadow: 0 0 0 3px rgba(239,68,68,.22);
}

/* =========================
   ✅ MODALS (عام)
   ========================= */
.modal{
  position:fixed;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:18px;
  z-index:999999;
  opacity:0;
  pointer-events:none;
  transition: opacity .22s ease;
}

/* overlay */
#modal{
  background:rgba(0,0,0,.65);
  backdrop-filter: blur(14px);
}
#codeModal{
  background:rgba(0,0,0,.58);
  backdrop-filter: blur(10px);
}

.modal.is-open{ opacity:1; pointer-events:auto; }
.modal.is-closing{ opacity:0; pointer-events:none; }

/* ✅ backdrop clickable area */
.modal-backdrop{
  position:absolute;
  inset:0;
  background:transparent;
  cursor:pointer;
}

/* panel base */
.modal .modal-panel{
  position:relative;
  animation: popIn .22s ease;
}

/* ✅ close button فقط */
.modal-close{
  cursor:pointer;
  position:absolute;
  top:14px;
  right:14px;
  width:44px;
  height:44px;
  border-radius:14px;
  border:1px solid rgba(239,68,68,.25);
  background:rgba(0,0,0,.25);
  color:rgba(255,243,244,.92);
  display:grid;
  place-items:center;
  transition: transform .15s ease, filter .15s ease, border-color .15s ease;
  z-index:8;
}
.modal-close:hover{
  transform: translateY(-1px);
  border-color: rgba(239,68,68,.55);
  filter: brightness(1.06);
}

/* =========================================================
   ✅ CODE MODAL (#codeModal) — مرتب أكثر + RTL
   ========================================================= */
#codeModal .modal-panel{
  width:min(560px, 94vw);
  border-radius:22px;
  background:linear-gradient(180deg, rgba(18,4,6,.96), rgba(12,3,5,.96));
  border:1px solid rgba(239,68,68,.38);
  box-shadow:
    0 30px 90px rgba(0,0,0,.60),
    0 0 0 1px rgba(255,255,255,.03) inset,
    0 0 70px rgba(239,68,68,.12);
  overflow:hidden;
}

.code-box{
  padding:22px 22px 20px;
  direction:rtl;
  text-align:right;
}

.code-title{
  font-weight:900;
  font-size:18px;
  color:rgba(255,243,244,.96);
}

.code-sub{
  margin-top:6px;
  margin-bottom:16px;
  color:rgba(255,243,244,.72);
  font-weight:700;
}

.code-input{
  width:100%;
  padding:14px 16px;
  border-radius:16px;
  border:1px solid rgba(239,68,68,.35);
  background:rgba(0,0,0,.22);
  color:var(--txt);
  font-size:16px;
  letter-spacing:6px;
  text-align:center;
}
.code-input::placeholder{ color: rgba(255,243,244,.45); }

.code-confirm{
  margin-top:14px;
  width:100%;
  padding:14px 18px;
  border-radius:16px;
  font-weight:900;
}

/* ✅ نخفي سطر "الرمز يتغير كل 5 دقائق" */
.code-hint{ display:none !important; }

/* Wrong / Ok effects على نفس panel */
#codeModal .modal-panel.is-wrong{
  border-color: rgba(239,68,68,.85);
  box-shadow:
    0 30px 90px rgba(0,0,0,.60),
    0 0 0 1px rgba(255,255,255,.03) inset,
    0 0 90px rgba(239,68,68,.22);
  animation: shake .16s ease-in-out 0s 6;
}
#codeModal .modal-panel.is-ok{
  border-color: rgba(34,197,94,.75);
  box-shadow:
    0 30px 90px rgba(0,0,0,.60),
    0 0 0 1px rgba(255,255,255,.03) inset,
    0 0 90px rgba(34,197,94,.18);
}

/* =========================================================
   ✅ IMAGE MODAL (#modal) — مرتب جدًا (العنوان فوق + وصف + أزرار تحت)
   ========================================================= */
#modal .modal-panel{
  width:min(1020px, 95vw);
  border-radius:26px;
  background:linear-gradient(180deg, rgba(18,4,6,.96), rgba(12,3,5,.96));
  border:1px solid rgba(239,68,68,.34);
  box-shadow:
    0 30px 110px rgba(0,0,0,.68),
    0 0 0 1px rgba(255,255,255,.03) inset,
    0 0 90px rgba(239,68,68,.10);
  overflow:hidden;
}

#modal .modal-body{
  display:grid;
  grid-template-columns: 1.25fr 1fr;
  gap:22px;
  padding:22px;
}

/* الصورة */
#modalImg{
  width:100%;
  height:100%;
  max-height:72vh;
  object-fit:cover;
  display:block;
  border-radius:20px;
  background:rgba(0,0,0,.18);
  border:1px solid rgba(239,68,68,.14);
}

/* عمود المعلومات - فوق مرتب */
#modal .modal-info{
  display:flex;
  flex-direction:column;
  justify-content:flex-start;
  padding:4px 2px 6px;
}

#modalTitle{
  margin:0;
  font-size:26px;
  font-weight:950;
  letter-spacing:.2px;
  color:rgba(255,243,244,.98);
  line-height:1.25;
}

/* خط فاصل لطيف */
#modal .modal-info::after{
  content:"";
  display:block;
  height:1px;
  width:100%;
  margin:14px 0 14px;
  background:linear-gradient(90deg, rgba(239,68,68,.55), rgba(239,68,68,.05));
  border-radius:999px;
}

#modalDesc{
  margin:0;
  color:rgba(255,243,244,.78);
  line-height:1.85;
  font-size:14.5px;
}

/* الأزرار تحت بشكل مرتب */
.modal-actions{
  margin-top:auto;
  display:flex;
  gap:12px;
  flex-wrap:wrap;
  padding-top:16px;
}

#modalDownloadBtn{
  padding:14px 22px;
}

/* تحسين زر Close داخل مودال الصورة */
#modal .modal-actions .btn.ghost{
  border-color: rgba(239,68,68,.22);
}

/* animations */
@keyframes popIn{
  from { transform: translateY(12px) scale(.985); opacity:.6; }
  to   { transform: translateY(0) scale(1); opacity:1; }
}

@keyframes shake{
  0% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
  100% { transform: translateX(0); }
}

@media (max-width: 900px){
  #modal .modal-body{
    grid-template-columns: 1fr;
  }
  #modalImg{
    max-height:55vh;
    object-fit:contain;
  }
  .modal-actions{
    margin-top:18px;
  }
}

@media (max-width:640px){
  .hero h1{ font-size:44px; }
  .projects h2{ font-size:34px; }
  .projects{ padding:45px 18px 70px; }
}
