/* هندسة محرك الدوران الانسيابي الداخلي وعزل زاوية المتصفح */
@property --angle {
  syntax: '<angle>';
  initial-value: 0deg;
  inherits: false;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --black: #050505;
  --white: #f0ede8;
  --dim: #6b6760;
  --gold: #c9a84c;
  --gold-glow: #ffd700;
  --card-bg: #0a0a0a; /* سواد الكارد الثابت والراقي من الداخل */
  --border: rgba(201, 168, 76, 0.22);
  --mono: monospace;
  --sans: "Montserrat", sans-serif;
}

html,
body {
  width: 100%;
  height: 100%;
  background: var(--black);
  color: var(--white);
  font-family: var(--sans);
  overflow: hidden;
}

/* ── NOISE OVERLAY ── */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E");
  background-size: 180px 180px;
  opacity: 0.35;
}

#sparkle-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
}

#bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: var(--black);
  transition: opacity 1.2s ease;
}
#bg img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 1.4s ease;
}
#bg-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(5, 5, 5, 0.55) 0%, rgba(5, 5, 5, 0.25) 40%, rgba(5, 5, 5, 0.75) 100%);
}

/* ── ENTER SCREEN ── */
#enter-screen {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--black);
  cursor: pointer;
  transition: opacity 0.9s ease, visibility 0.9s ease;
}
#enter-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.enter-title {
  font-family: var(--sans);
  font-size: clamp(3.5rem, 10vw, 7rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--white);
  line-height: 1;
  text-align: center;
}
.enter-title span { color: var(--gold); }
.enter-sub {
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.25em;
  color: var(--dim);
  margin-top: 2rem;
  text-transform: uppercase;
  animation: blink-cursor 1.1s step-end infinite;
}
@keyframes blink-cursor { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

#enter-screen::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(255, 255, 255, 0.013) 2px, rgba(255, 255, 255, 0.013) 4px);
  pointer-events: none;
}

#main {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 1s ease 0.4s;
  pointer-events: none;
}
#main.visible { opacity: 1; pointer-events: auto; }

/* ── CARD (وضع الكمبيوتر: كارد أصلي ثابت وهادي جداً بنسبة 100% وبدون جليتشات) ── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 2.4rem 2.8rem 2.2rem;
  width: min(420px, 92vw);
  backdrop-filter: blur(18px) saturate(1.3);
  -webkit-backdrop-filter: blur(18px) saturate(1.3);
  position: relative;
  transition: border-color 0.3s ease;
}

/* خط الإطار العلوي الذهبي اللامع لموقع dien.pw */
.card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent 0%, var(--gold) 40%, var(--gold-glow) 60%, transparent 100%);
  opacity: 0.6;
  z-index: 5;
}

/* ── HEADER ── */
.card-header { display: flex; align-items: center; gap: 1.4rem; margin-bottom: 1.4rem; position: relative; z-index: 6; }
.avatar-wrap { position: relative; flex-shrink: 0; }
.avatar-wrap::after {
  content: ""; position: absolute; inset: -3px; border-radius: 14px;
  background: conic-gradient(var(--gold) 0deg, transparent 60deg, var(--gold) 120deg, transparent 180deg, var(--gold) 240deg, transparent 300deg, var(--gold) 360deg);
  z-index: -1; rotate: 80deg; opacity: 0.7;
}
.avatar { width: 78px; height: 78px; border-radius: 12px; object-fit: cover; display: block; position: relative; z-index: 1; background: #1a1a1a; }

.handle { font-family: var(--sans); font-size: 1.65rem; font-weight: 800; letter-spacing: -0.03em; line-height: 1; color: var(--white); }
.bio { font-family: var(--mono); font-size: 0.78rem; color: var(--dim); margin-top: 0.45rem; letter-spacing: 0.02em; line-height: 1.6; }
.bio .highlight { color: var(--gold); text-shadow: 0 0 8px rgba(255, 215, 0, 0.4); }

.divider { height: 1px; background: linear-gradient(90deg, transparent, var(--border) 30%, var(--border) 70%, transparent); margin: 1.4rem 0; position: relative; z-index: 6; }

/* ── LINKS & THE INNER SHIELD (حماية السواد الملكي ومنع التسريب بالملي) ── */
.links { display: flex; flex-direction: column; gap: 0.65rem; position: relative; z-index: 6; }

.link-btn {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.72rem 1.1rem;
  border-radius: 10px;
  color: var(--white);
  text-decoration: none;
  font-family: var(--mono);
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  position: relative;
  z-index: 1;
  
  /* الحصن البرمجي الذكي للإطار المعزول */
  border: 1.5px solid transparent;
  background: linear-gradient(#0a0a0a, #0a0a0a) padding-box, 
              var(--btn-glow-bg) border-box;
  background-size: 100% 100%;
  
  /* الاختفاء التدريجي (Fade-out) الانسيابي والناعم جداً */
  transition: transform 0.15s, box-shadow 0.25s ease, background 0.7s cubic-bezier(0.4, 0, 0.2, 1);
}

/* طبقة الـ Intro الملونة: pseudo-element معزول بالكامل يدور ويطفي بسلاسة */
.link-btn::after {
  content: "";
  position: absolute;
  inset: -1.5px;
  border-radius: inherit;
  background: var(--btn-intro-glow);
  opacity: 0;
  z-index: -1;
  pointer-events: none;
  transition: opacity 0.8s ease;
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask-composite: exclude;
  padding: 1.5px;
}

/* ألوان طبقة الـ Intro لكل زر */
.telegram-btn { --btn-intro-glow: conic-gradient(from var(--angle), transparent 50%, #1d93d2 85%, #38b0e3 98%, transparent 100%); --shadow-glow: rgba(0, 136, 204, 0.35); }
.whatsapp-btn { --btn-intro-glow: conic-gradient(from var(--angle), transparent 60%, #1ea952 85%, #4ced69 98%, transparent 100%); --shadow-glow: rgba(37, 211, 102, 0.35); }
.github-btn   { --btn-intro-glow: conic-gradient(from var(--angle), transparent 60%, #444444 85%, #ffffff 98%, transparent 100%); --shadow-glow: rgba(255, 255, 255, 0.2); }

/* جعل الإطار الافتراضي الخارجي خافتاً جداً ومظلماً عند إيقاف الـ Hover */
.telegram-btn { --btn-glow-bg: conic-gradient(from var(--angle), rgba(255,255,255,0.06) 100%, transparent 0%); }
.whatsapp-btn { --btn-glow-bg: conic-gradient(from var(--angle), rgba(255,255,255,0.06) 100%, transparent 0%); }
.github-btn   { --btn-glow-bg: conic-gradient(from var(--angle), rgba(255,255,255,0.06) 100%, transparent 0%); }

/* تشغيل تدوير الـ Intro: يظهر الضوء + يدور */
.link-btn.intro-flash,
.link-btn.intro-fading {
  animation: spinAngleWheel 2.2s linear infinite;
}
.link-btn.intro-flash::after,
.link-btn.intro-fading::after {
  animation: spinAngleWheel 2.2s linear infinite;
}

/* الظهور الكامل أثناء الـ Intro */
.link-btn.intro-flash::after {
  opacity: 1;
  transition: none;
}

/* الاختفاء التدريجي الناعم خلال 0.8 ثانية مع استمرار الدوران */
.link-btn.intro-fading::after {
  opacity: 0;
  transition: opacity 0.8s ease;
}

/* تشغيل تدوير زاوية شعاع النور الملون عند الـ Hover (الدسكتوب فقط) */
.link-btn:hover {
  animation: spinAngleWheel 2.2s linear infinite;
  --btn-glow-bg: var(--btn-hover-glow, conic-gradient(from var(--angle), rgba(255,255,255,0.06) 100%, transparent 0%));
}

/* توزيع الألوان الهادئة حول المنصات عند الـ Hover */
.telegram-btn:hover { --btn-hover-glow: conic-gradient(from var(--angle), transparent 50%, #1d93d2 85%, #38b0e3 98%, transparent 100%); }
.whatsapp-btn:hover { --btn-hover-glow: conic-gradient(from var(--angle), transparent 60%, #1ea952 85%, #4ced69 98%, transparent 100%); }
.github-btn:hover   { --btn-hover-glow: conic-gradient(from var(--angle), transparent 60%, #444444 85%, #ffffff 98%, transparent 100%); }

@keyframes spinAngleWheel {
  to { --angle: 360deg; }
}

.link-btn:hover {
  transform: translateX(4px);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5), 0 0 15px var(--shadow-glow);
}
.link-btn:active { transform: translateX(2px) scale(0.99); }

.link-icon { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: 8px; background: rgba(255, 255, 255, 0.06); flex-shrink: 0; }
.link-label { flex: 1; }
.link-meta { font-size: 0.68rem; color: var(--dim); }

/* ── CARD FOOTER ── */
.card-footer {
  margin-top: 1.8rem; display: flex; align-items: center; justify-content: center; gap: 0.5rem;
  font-family: var(--mono); font-size: 0.64rem; color: var(--dim); letter-spacing: 0.1em;
  width: 100%; position: relative; z-index: 6;
}
.footer-dot { width: 4px; height: 4px; border-radius: 50%; background: var(--gold); opacity: 0.5; animation: pulse-dot 2.4s ease-in-out infinite; }
@keyframes pulse-dot { 0%, 100% { opacity: 0.3; transform: scale(1); } 50% { opacity: 0.9; transform: scale(1.4); } }

/* ── MUSIC BAR ── */
#music-bar {
  position: fixed; bottom: 1.6rem; right: 1.6rem; z-index: 200; display: flex; align-items: center; gap: 0.6rem;
  background: rgba(10, 10, 10, 0.8); border: 1px solid var(--border); border-radius: 40px; padding: 0.5rem 0.9rem;
  backdrop-filter: blur(12px); cursor: pointer; opacity: 0; transform: translateY(12px);
  transition: opacity 0.6s ease 1.2s, transform 0.6s ease 1.2s, background 0.2s; font-family: var(--mono); font-size: 0.7rem; color: var(--dim); user-select: none;
}
#music-bar.visible { opacity: 1; transform: translateY(0); }
#music-bar:hover { background: rgba(20, 20, 20, 0.95); color: var(--white); }
.music-bars { display: flex; align-items: flex-end; gap: 2px; height: 14px; }
.music-bar-line { width: 3px; border-radius: 2px; background: var(--gold); animation: bar-dance 0.8s ease-in-out infinite; transform-origin: bottom; }
.music-bar-line:nth-child(1) { height: 6px; animation-delay: 0s; }
.music-bar-line:nth-child(2) { height: 10px; animation-delay: 0.15s; }
.music-bar-line:nth-child(3) { height: 14px; animation-delay: 0.3s; }
.music-bar-line:nth-child(4) { height: 8px; animation-delay: 0.1s; }
.music-bar-line.paused { animation-play-state: paused; height: 3px !important; }

@keyframes bar-dance { 0%, 100% { transform: scaleY(0.3); } 50% { transform: scaleY(1); } }

/* ── 📱 وضع الموبايل الفخم (حل مشكلة الكارد نهائياً بحصر زاوية الضوء من الداخل بدون تفكك) ── */
@media (max-width: 768px) {
  #main { padding: 15px; }
  
  /* حماية الفوتر بزيادة مساحة الحشو لحمايته بالكامل */
  .card {
    padding: 2.4rem 2rem 2.5rem;
    border: 1.5px solid transparent !important;
    
    /* تفعيل خط النور الدائري والذهبي ليلف حول الكارد باستمرار عبر الـ CSS ومنع سقوط الألوان */
    background: linear-gradient(var(--card-bg), var(--card-bg)) padding-box,
                conic-gradient(from var(--angle), transparent 60%, var(--gold) 75%, #ffffff 96%, transparent 100%) border-box !important;
    animation: spinAngleWheel 4.5s linear infinite !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  }
}

/* ══════════════════════════════════════════════════════
   ██  PROJECTS SECTION — Expand/Collapse Panel
   ══════════════════════════════════════════════════════ */

/* ── Projects Divider ── */
.projects-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border) 30%, var(--border) 70%, transparent);
  margin: 1.4rem 0;
  position: relative;
  z-index: 6;
}

/* ── Projects Toggle Button ── */
.projects-toggle-btn {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.72rem 1.1rem;
  border-radius: 10px;
  color: var(--white);
  text-decoration: none;
  font-family: var(--mono);
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  position: relative;
  z-index: 6;
  cursor: pointer;
  width: 100%;

  border: 1.5px solid transparent;
  background: linear-gradient(#0a0a0a, #0a0a0a) padding-box,
              linear-gradient(135deg, rgba(201, 168, 76, 0.35), rgba(255, 215, 0, 0.12), rgba(201, 168, 76, 0.35)) border-box;

  transition: transform 0.15s, box-shadow 0.25s ease, background 0.3s ease;
}

.projects-toggle-btn:hover {
  background: linear-gradient(rgba(201, 168, 76, 0.04), rgba(201, 168, 76, 0.02)) padding-box,
              linear-gradient(135deg, rgba(201, 168, 76, 0.5), rgba(255, 215, 0, 0.2), rgba(201, 168, 76, 0.5)) border-box;
  transform: translateX(4px);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5), 0 0 15px rgba(201, 168, 76, 0.2);
}

.projects-toggle-btn:active {
  transform: translateX(2px) scale(0.99);
}

/* Toggle icon (chevron) */
.projects-toggle-btn .toggle-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
}

.projects-toggle-btn.expanded .toggle-icon {
  transform: rotate(180deg);
}

/* Toggle button icon container — matches .link-icon */
.projects-toggle-btn .link-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: rgba(201, 168, 76, 0.1);
  flex-shrink: 0;
}

/* ── Projects Panel (expand/collapse container) ── */
#projects-panel {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.5s ease, opacity 0.4s ease;
  position: relative;
  z-index: 6;
}

#projects-panel.expanded {
  opacity: 1;
  padding-top: 0.65rem;
}

/* ── Project Cards ── */
.project-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.72rem 1.1rem;
  border-radius: 10px;
  color: var(--white);
  text-decoration: none;
  font-family: var(--mono);
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  position: relative;
  z-index: 1;
  margin-bottom: 0.65rem;

  border: 1.5px solid rgba(201, 168, 76, 0.15);
  background: #0a0a0a;

  transition: transform 0.15s, box-shadow 0.25s ease, border-color 0.3s ease;
}

.project-card:last-child {
  margin-bottom: 0;
}

.project-card:hover {
  transform: translateX(4px);
  border-color: rgba(201, 168, 76, 0.35);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5), 0 0 18px rgba(201, 168, 76, 0.12);
}

.project-card:active {
  transform: translateX(2px) scale(0.99);
}

/* Project card content layout */
.project-info {
  flex: 1;
  min-width: 0;
}

.project-name {
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--white);
  letter-spacing: 0.04em;
}

.project-desc {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--dim);
  margin-top: 0.2rem;
  line-height: 1.4;
  letter-spacing: 0.02em;
}

.project-arrow {
  flex-shrink: 0;
  color: var(--dim);
  transition: color 0.2s ease, transform 0.2s ease;
}

.project-card:hover .project-arrow {
  color: var(--gold);
  transform: translateX(2px);
}

/* Stagger entrance animation for project cards */
#projects-panel.expanded .project-card {
  animation: fadeSlideIn 0.35s ease-out both;
}

#projects-panel.expanded .project-card:nth-child(1) { animation-delay: 0ms; }
#projects-panel.expanded .project-card:nth-child(2) { animation-delay: 80ms; }
#projects-panel.expanded .project-card:nth-child(3) { animation-delay: 160ms; }
#projects-panel.expanded .project-card:nth-child(4) { animation-delay: 240ms; }
#projects-panel.expanded .project-card:nth-child(5) { animation-delay: 320ms; }
#projects-panel.expanded .project-card:nth-child(6) { animation-delay: 400ms; }
#projects-panel.expanded .project-card:nth-child(7) { animation-delay: 480ms; }
#projects-panel.expanded .project-card:nth-child(8) { animation-delay: 560ms; }

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


/* ══════════════════════════════════════════════════════
   ██  MOBILE PARALLAX & GYROSCOPE ENHANCEMENTS
   ══════════════════════════════════════════════════════ */

/* Card entrance animation (mobile) */
@keyframes cardEntranceMobile {
  from {
    transform: translateY(40px) scale(0.96);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

/* Avatar float animation (mobile) */
@keyframes avatarFloat {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-4px); }
}

@media (max-width: 768px) {

  /* ── Background Parallax ── */
  #bg img {
    transition: opacity 1.4s ease, transform 0.15s ease-out;
  }
  #bg img.parallax-active {
    /* JS sets transform via gyroscope data; this just enables smooth interpolation */
  }

  /* ── Mobile Scroll & Overflow for Projects ── */
  #main {
    overflow-y: auto;
    align-items: flex-start;
    padding-top: 5vh;
    scroll-behavior: smooth;
    scrollbar-width: none;  /* Firefox */
  }
  #main::-webkit-scrollbar {
    display: none;  /* Chrome/Safari */
  }

  /* ── Card Entrance Animation (mobile) ── */
  #main.visible .card {
    animation: cardEntranceMobile 0.8s ease-out both,
               spinAngleWheel 4.5s linear infinite;
  }

  /* ── Mobile Card Gold Glow Depth ── */
  .card {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 30px rgba(201, 168, 76, 0.08);
  }

  /* ── Avatar Float Animation (mobile) ── */
  .avatar-wrap {
    animation: avatarFloat 3s ease-in-out infinite;
  }

  /* ── Touch Active States (mobile) ── */
  .link-btn:active {
    transform: scale(0.97);
    box-shadow: 0 0 12px rgba(201, 168, 76, 0.15);
  }

  .project-card:active {
    transform: scale(0.97);
    box-shadow: 0 0 12px rgba(201, 168, 76, 0.15);
  }

  /* ── Projects toggle mobile active ── */
  .projects-toggle-btn:active {
    transform: scale(0.97);
    box-shadow: 0 0 12px rgba(201, 168, 76, 0.15);
  }
}