@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700&display=swap');

:root {
  /* Dark Theme Palette (Default) */
  --bg-dark: #050505;
  --bg-card: #0F0F0F;
  --bg-card-hover: #161616;
  
  --text-white: #FFFFFF;
  --text-gray: #A1A1AA;
  --text-dark: #000000;
  
  --border-color: #27272A;
  --accent-color: #FFFFFF; 
  --nav-bg: rgba(5, 5, 5, 0.7);

  /* Spacing */
  --space-4: 1rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-16: 4rem;
  --space-24: 6rem;

  /* Radius */
  --radius-lg: 16px;
  --radius-pill: 100px;

  /* Fonts */
  --font-family: 'Inter', system-ui, -apple-system, sans-serif;
  --font-arabic: 'Cairo', 'Inter', sans-serif;
}

[data-theme="light"] {
  --bg-dark: #FAFAFA;
  --bg-card: #FFFFFF;
  --bg-card-hover: #F0F0F0;
  
  --text-white: #111111;
  --text-gray: #555555;
  --text-dark: #FFFFFF;
  
  --border-color: #E0E0E0;
  --accent-color: #111111;
  --nav-bg: rgba(250, 250, 250, 0.8);
}

/* Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-dark);
  color: var(--text-white);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.4s ease, color 0.4s ease, opacity 0.5s ease-in-out; 
}

/* RTL Support */
body.rtl {
  direction: rtl;
  text-align: right;
  font-family: var(--font-arabic);
}
body.rtl .hero-tagline::after {
  margin-left: 0;
  margin-right: 4px;
}
body.rtl .nav-menu {
  flex-direction: row-reverse;
}
body.rtl .nav-logo {
  margin-right: 0;
  margin-left: auto;
}
body.rtl .nav-toggles {
  margin-left: 0;
  margin-right: var(--space-4);
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-6);
}

/* Navigation */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: var(--nav-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-color);
  transition: all 0.3s ease;
}

.nav-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.2rem var(--space-6);
}

.nav-logo .logo-text {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-white);
  letter-spacing: -0.5px;
}

.nav-menu {
  display: flex;
  list-style: none;
  gap: 2.5rem;
  margin: 0 auto;
}

.nav-link {
  text-decoration: none;
  color: var(--text-gray);
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.2s ease;
  position: relative;
}

.nav-link:hover, .nav-link.active {
  color: var(--text-white);
  font-weight: 600;
}

.nav-link.active::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 100%;
  height: 1px;
  background: var(--text-white);
}

.nav-toggles {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.btn-icon {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-white);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: bold;
    transition: all 0.3s ease;
}

.btn-icon:hover {
    background: var(--text-white);
    color: var(--bg-dark);
}

/* Hero Section */
.hero {
  min-height: 100vh;
  display: flex;
  align-items: center;
  position: relative;
  overflow: hidden;
  padding-top: 80px;
}

.hero-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  gap: var(--space-8);
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-6);
  z-index: 2;
}

.hero-title {
  font-size: 3rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin-bottom: 1.5rem;
  color: var(--text-white);
}

.hero-tagline {
  display: block;
  font-size: 1.1rem;
  color: var(--text-gray);
  margin-bottom: 0.5rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.profile-section {
    margin: 1.5rem 0 2.5rem;
}

.bio-text {
    font-size: 1.1rem;
    color: var(--text-gray);
    line-height: 1.6;
    margin-bottom: 2rem;
}

.links-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.project-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-white);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s;
}

.project-btn:hover {
    background: var(--text-white);
    color: var(--text-dark);
}

.hero-buttons {
  display: flex;
  gap: 1rem;
}

.btn-primary, .btn-secondary, .btn-outline {
  padding: 0.9rem 2rem;
  border-radius: var(--radius-pill);
  font-size: 1rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.3s ease;
  border: 1px solid transparent;
}

.btn-primary {
  background: var(--text-white);
  color: var(--text-dark);
  border: 1px solid var(--text-white);
}

.btn-primary:hover {
  background: transparent;
  color: var(--text-white);
}

.btn-secondary {
  background: transparent;
  color: var(--text-white);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  border-color: var(--text-white);
  background: rgba(128, 128, 128, 0.1);
}

.btn-outline {
  background: transparent;
  color: var(--text-white);
  border: 1px solid var(--border-color);
  width: 100%;
}

.btn-outline:hover {
  background: var(--text-white);
  color: var(--text-dark);
}

.hero-visual {
  height: 500px;
  width: 100%;
  position: relative;
}

spline-viewer {
  width: 100%;
  height: 100%;
}

/* Sections Base */
.section-header {
  text-align: center;
  margin-bottom: 3.5rem;
}

.section-title {
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--text-white);
  display: inline-block;
}

.section-subtitle {
  color: var(--text-gray);
  font-size: 1.1rem;
  margin-top: 0.5rem;
}

.header-line {
    width: 60px;
    height: 3px;
    background: var(--text-white);
    margin: 1rem auto 0;
    border-radius: 3px;
}

/* About Section */
.about-section {
    padding: var(--space-16) 0;
    background: var(--bg-dark);
}

.about-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 3rem;
}

.about-text p {
    color: var(--text-gray);
    margin-bottom: 1.5rem;
    font-size: 1.05rem;
}

.edu-box, .cert-box {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    margin-bottom: 2rem;
}

.edu-box h3, .cert-box h3 {
    margin-bottom: 1rem;
    color: var(--text-white);
    display: flex;
    align-items: center;
    gap: 8px;
}

.edu-box ul, .cert-box ul {
    list-style: none;
}

.edu-box li {
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
}

.edu-box strong { color: var(--text-white); }
.edu-box span { color: var(--text-gray); font-size: 0.9rem; }

.cert-list li {
    position: relative;
    padding: 0.3rem 0;
    padding-left: 1.5rem;
    color: var(--text-gray);
    font-size: 0.95rem;
}

body.rtl .cert-list li {
    padding-left: 0;
    padding-right: 1.5rem;
}

.cert-list li::before {
    content: '✓';
    position: absolute;
    left: 0;
    color: var(--text-white);
}

body.rtl .cert-list li::before {
    left: auto;
    right: 0;
}

.skills-container {
    margin-top: 3rem;
    text-align: center;
}

.subsection-title {
    color: var(--text-white);
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
}

.skills-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
}

.skill-tag {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-white);
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    transition: all 0.3s;
}

.skill-tag:hover {
    border-color: var(--text-white);
    background: var(--text-white);
    color: var(--text-dark);
}

/* Experience Timeline */
.experience {
    padding: var(--space-16) 0;
    background: var(--bg-card);
}

.timeline {
    position: relative;
    max-width: 800px;
    margin: 0 auto;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 20px;
    top: 0;
    height: 100%;
    width: 2px;
    background: var(--border-color);
}

body.rtl .timeline::before {
    left: auto;
    right: 20px;
}

.timeline-item {
    position: relative;
    padding-left: 50px;
    margin-bottom: 3rem;
}

body.rtl .timeline-item {
    padding-left: 0;
    padding-right: 50px;
}

.timeline-dot {
    position: absolute;
    left: 12px;
    top: 5px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--text-white);
    border: 4px solid var(--bg-card);
}

body.rtl .timeline-dot {
    left: auto;
    right: 12px;
}

.timeline-content {
    background: var(--bg-dark);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    transition: transform 0.3s;
}

.timeline-content:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.exp-header {
    margin-bottom: 1rem;
}

.exp-header h3 {
    color: var(--text-white);
    font-size: 1.3rem;
    margin-bottom: 0.2rem;
}

.exp-company {
    color: var(--text-white);
    font-weight: 600;
    margin-right: 1rem;
}

.exp-date {
    color: var(--text-gray);
    font-size: 0.9rem;
}

.exp-details {
    list-style: none;
    margin-top: 1rem;
}

.exp-details li {
    color: var(--text-gray);
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
    padding-left: 1.2rem;
    position: relative;
}

body.rtl .exp-details li {
    padding-left: 0;
    padding-right: 1.2rem;
}

.exp-details li::before {
    content: '-';
    position: absolute;
    left: 0;
}

body.rtl .exp-details li::before {
    left: auto;
    right: 0;
}

/* Events (Projects) */
.events {
    padding: var(--space-16) 0;
    background: var(--bg-dark);
}

.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
}

.project-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all 0.3s ease;
}

.project-card:hover {
    transform: translateY(-5px);
    border-color: rgba(128,128,128,0.5);
}

.project-image {
    height: 180px;
    background: var(--bg-dark);
    display: flex;
    align-items: center;
    justify-content: center;
}

.placeholder-img {
    font-size: 4rem;
    color: rgba(255, 255, 255, 0.4);
}

[data-theme="light"] .placeholder-img {
    color: rgba(0, 0, 0, 0.4);
}

.project-content {
    padding: 1.5rem;
}

.project-title {
    font-size: 1.2rem;
    color: var(--text-white);
    margin-bottom: 0.5rem;
}

.project-description {
    color: var(--text-gray);
    font-size: 0.9rem;
}

/* GAMES SECTION */
.games-section {
    padding: var(--space-16) 0;
    background: var(--bg-card);
}

.games-layout {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.game-container {
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.game-container h3 {
    margin-bottom: 0.5rem;
    color: var(--text-white);
}

/* TTT specific */
.ttt-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
    background: var(--border-color);
    width: 150px;
    height: 150px;
    margin: 1rem auto;
}
.ttt-cell {
    background: var(--bg-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: bold;
    color: var(--text-white);
    cursor: pointer;
}

/* RPS specific */
.rps-choices {
    display: flex;
    gap: 1rem;
    margin: 1rem 0;
}
.rps-btn {
    font-size: 2rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-white);
    border-radius: 50%;
    width: 60px;
    height: 60px;
    cursor: pointer;
}
.rps-btn:hover { background: var(--text-white); color: var(--text-dark); }
.rps-result { min-height: 2rem; font-weight: bold; color: var(--text-white);}

/* Memory specific */
.mem-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin: 1rem auto;
}
.mem-card {
    width: 50px;
    height: 50px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    cursor: pointer;
    color: transparent; /* hidden by default */
    transition: background 0.3s;
}
.mem-card.flipped {
    background: var(--text-white);
    color: var(--text-dark);
}
.mem-card.matched {
    background: rgba(0, 255, 0, 0.2);
    color: var(--text-white);
}

.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }

/* Contact Section */
.contact {
    padding: var(--space-16) 0;
    background: var(--bg-dark);
}

.contact-grid {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 4rem;
}

.contact-item {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.contact-icon {
    width: 50px;
    height: 50px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: var(--text-white);
}

.contact-details h4 {
    color: var(--text-gray);
    font-size: 0.9rem;
    margin-bottom: 0.2rem;
}

.contact-details a {
    color: var(--text-white);
    font-size: 1.1rem;
    text-decoration: none;
}

.social-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-white);
    transition: all 0.2s;
}

.social-link:hover {
    background: var(--text-white);
    color: var(--text-dark);
}

.contact-form-container {
    background: var(--bg-card);
    padding: 2.5rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.form-input {
    width: 100%;
    padding: 1rem;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-white);
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: var(--text-white);
}

.btn-submit {
    width: 100%;
    padding: 1rem;
    background: var(--text-white);
    color: var(--text-dark);
    border: none;
    border-radius: var(--radius-pill);
    font-weight: 600;
    cursor: pointer;
    font-size: 1rem;
    transition: opacity 0.2s;
}

.footer {
    padding: 2rem 0;
    text-align: center;
    border-top: 1px solid var(--border-color);
    color: var(--text-gray);
    font-size: 0.9rem;
    background: var(--bg-dark);
}

@media (max-width: 768px) {
  .hero-container, .about-grid, .contact-grid {
    grid-template-columns: 1fr;
    text-align: center;
  }
  
  .hero-visual {
    height: 300px;
    order: -1;
  }

  .nav-menu {
    display: none;
  }
  
  .links-grid { justify-content: center; }
  .skills-tags { justify-content: center; }

  .hero-buttons { justify-content: center; }
  
  body.rtl .timeline::before, .timeline::before { left: 50%; transform: translateX(-50%); }
  
  .timeline-item, body.rtl .timeline-item {
      padding: 0;
      text-align: center;
      margin-top: 40px;
  }
  .timeline-dot, body.rtl .timeline-dot {
      left: 50%;
      transform: translateX(-50%);
      top: -30px;
  }
}