/* ==================== Base Styles ==================== */
html {
  scroll-behavior: smooth;
  caret-color: transparent !important; /* Hide caret by default everywhere */
}

/* Default (bg1/light) theme caret colors */
#contact .contact-form input[type="text"],
#contact .contact-form input[type="email"],
#contact .contact-form textarea {
  caret-color: transparent; /* Hide caret by default */
  color: #ffffff;
  transition: all 0.3s ease;
}

/* Show caret when focused - bg1 (light) theme */
body.bg1 #contact .contact-form input[type="text"]:focus,
body.bg1 #contact .contact-form input[type="email"]:focus,
body.bg1 #contact .contact-form textarea:focus {
  caret: 1px solid #071E3D; /* Thinner caret with better browser support */
  outline: none;
  box-shadow: 0 0 0 2px rgba(33, 230, 193, 0.3);
  background-color: rgba(255, 255, 255, 0.1);
}

/* bg2 (dark) theme caret colors */
body.bg2 #contact .contact-form input[type="text"],
body.bg2 #contact .contact-form input[type="email"],
body.bg2 #contact .contact-form textarea {
  caret-color: transparent; /* Hide caret by default in dark theme */
}

/* Show caret when focused - bg2 (dark) theme */
body.bg2 #contact .contact-form input[type="text"]:focus,
body.bg2 #contact .contact-form input[type="email"]:focus,
body.bg2 #contact .contact-form textarea:focus {
  caret: 1px solid #ffc800; /* Thinner caret with better browser support */
  outline: none;
  box-shadow: 0 0 0 2px rgba(255, 200, 0, 0.3);
  background-color: rgba(0, 0, 0, 0.2);
}

/* Selection styling for better visibility */
#contact .contact-form input[type="text"]::selection,
#contact .contact-form input[type="email"]::selection,
#contact .contact-form textarea::selection {
  background: rgba(33, 230, 193, 0.3);
  color: #ffffff;
}

/* Dark theme selection */
body.bg2 #contact .contact-form input[type="text"]::selection,
body.bg2 #contact .contact-form input[type="email"]::selection,
body.bg2 #contact .contact-form textarea::selection {
  background: rgba(255, 200, 0, 0.3);
  color: #ffffff;
}

/* Ensure all other inputs and textareas have no caret */
input:not(#contact .contact-form input),
textarea:not(#contact .contact-form textarea) {
  caret-color: transparent !important;
}

body {
  background-color: #202020;
  background-repeat: no-repeat;
  background-size: cover;
  overflow-y: auto;
  overflow-x: hidden;
  background-attachment: fixed;
  background-position: center;
}

/* ==================== Loading Animation (Pyramid) ==================== */
.loader {
  display: flex;
  align-items: center;
  justify-content: center;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10000;
}

.pyramid-loader {
  position: relative;
  width: 300px;
  height: 300px;
  display: block;
  transform-style: preserve-3d;
  transform: rotateX(-20deg);
}

.wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  animation: spin 4s linear infinite;
}

@keyframes spin {
  to {
    transform: rotateY(360deg);
  }
}

.pyramid-loader .wrapper .side {
  width: 70px;
  height: 70px;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  margin: auto;
  transform-origin: center top;
  clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
}

.pyramid-loader .wrapper .side1 {
  background: conic-gradient(#2bdeac, #f028fd, #d8cce6, #2f2585);
  transform: rotateZ(-30deg) rotateY(90deg);
}

.pyramid-loader .wrapper .side2 {
  background: conic-gradient(#2f2585, #d8cce6, #f028fd, #2bdeac);
  transform: rotateZ(30deg) rotateY(90deg);
}

.pyramid-loader .wrapper .side3 {
  background: conic-gradient(#2f2585, #d8cce6, #f028fd, #2bdeac);
  transform: rotateX(30deg);
}

.pyramid-loader .wrapper .side4 {
  background: conic-gradient(#2bdeac, #f028fd, #d8cce6, #2f2585);
  transform: rotateX(-30deg);
}

.pyramid-loader .wrapper .shadow {
  width: 60px;
  height: 60px;
  background: #8b5ad5;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  margin: auto;
  transform: rotateX(90deg) translateZ(-40px);
  filter: blur(12px);
}

/* ==================== Navigation Styles ==================== */

/* Default/Fallback navbar colors - applied BEFORE JavaScript loads */
/* Theme switcher background - using both ID and class selectors */
body.bg1 #ini,
body.bg1 #ini-mobile,
body.bg1 .ini-bg,
body.bg1 .nav-bg {
  background-color: #21E6C1 !important;
}

body.bg2 #ini,
body.bg2 #ini-mobile,
body.bg2 .ini-bg,
body.bg2 .nav-bg {
  background-color: #ffc800 !important;
}

.mobile-nav-toggle {
  background-color: #21E6C1;
}

.mobile-nav-toggle span {
  background-color: #071e3d;
}


.nav_item {
  cursor: pointer;
}

.desktop-nav-items .nav_item:hover {
  text-decoration: underline;
  text-underline-offset: 4px;
}

.active {
  color: #071e3d;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.active2 {
  color: #1f0701;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.change-theme-text {
  color: #071e3d;
  transition: color 200ms ease;
}

body.bg2 .change-theme-text {
  color: #1f0701;
}

/* Default colors for desktop nav items by theme (non-active) */
body.bg1 .desktop-nav-items .nav_item:not(.active):not(.active2) {
  color: #071e3d83;
}

body.bg2 .desktop-nav-items .nav_item:not(.active):not(.active2) {
  color: #1f070183;
}

/* Hover colors for desktop nav items by theme */
body.bg1 .desktop-nav-items .nav_item:hover {
  color: #071E3D;
}

body.bg2 .desktop-nav-items .nav_item:hover {
  color: #1f0701;
}

/* ==================== Mobile Navigation ==================== */
.mobile-nav-toggle {
  display: none;
  cursor: pointer;
  padding: 0.75rem;
  border-radius: 1.5rem;
  transition: all 0.3s ease;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  margin-right: 1rem; /* Added margin */
}

.mobile-nav-toggle span {
  display: block;
  width: 24px;
  height: 2.5px;
  margin: 4px 0;
  transition: all 0.3s ease;
  border-radius: 2px;
}

.mobile-nav-toggle.active span:nth-child(1) {
  transform: rotate(45deg) translate(7px, 7px);
}

.mobile-nav-toggle.active span:nth-child(2) {
  opacity: 0;
}

.mobile-nav-toggle.active span:nth-child(3) {
  transform: rotate(-45deg) translate(7px, -7px);
}

.mobile-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 1rem;
  right: auto; /* Changed to auto to prevent stretching */
  margin-top: 0.5rem;
  border-radius: 1rem;
  overflow: visible;
  opacity: 0;
  transform: translateY(-10px);
  transition: all 0.3s ease;
  z-index: 50;
  background-color: transparent;
  box-shadow: none;
}

.mobile-menu.show {
  display: block;
  opacity: 1;
  transform: translateY(0);
}

.mobile-menu ul {
  flex-direction: column;
  gap: 0.75rem !important; /* Increased gap slightly */
  padding: 0.5rem 0;
  align-items: flex-start; /* Ensure left alignment */
}

.mobile-menu li {
  width: fit-content; /* Only wrap content */
}

.mobile-menu a {
  display: block;
  width: auto; /* Only wrap content */
  padding: 0.5rem 1.25rem; /* Adjusted padding for pill shape */
  text-align: left;
  transition: all 0.2s ease;
  border-radius: 9999px;
  font-weight: bold;
  white-space: nowrap; /* Prevent text wrapping */
}

/* Theme-specific backgrounds for mobile menu items */
body.bg1 .mobile-menu a {
  background-color: #21E6C1;
  color: #071e3d83;
  box-shadow: 0 4px 6px rgba(33, 230, 193, 0.2);
}

body.bg2 .mobile-menu a {
  background-color: #ffc800;
  color: #1f070183;
  box-shadow: 0 4px 6px rgba(255, 200, 0, 0.2);
}

.mobile-menu a:hover {
  filter: brightness(110%);
  text-decoration: underline;
  text-underline-offset: 4px;
}

/* Active colors for mobile menu items by theme */
body.bg1 .mobile-menu a.active {
  color: #071E3D;
}

body.bg2 .mobile-menu a.active2 {
  color: #1f0701;
}

/* Hover text colors for mobile menu items by theme */
body.bg1 .mobile-menu a:hover {
  color: #071E3D;
}

body.bg2 .mobile-menu a:hover {
  color: #1f0701;
}

@media (max-width: 767px) {
  nav .container {
    justify-content: space-between !important;
    width: 100%;
  }

  .desktop-nav-items {
    display: none !important;
  }

  .mobile-nav-toggle {
    display: block;
  }

  nav {
    position: fixed; /* Fix position for margins to work */
    width: auto !important;
    top: 0.75rem;
    left: max(0.75rem, env(safe-area-inset-left));
    right: max(0.75rem, env(safe-area-inset-right));
    margin-inline: 0;
    background: transparent !important;
    box-shadow: none !important;
    padding: 0 !important;
  }
  
  /* Force transparent background on nav container for mobile, overriding theme rules */
  body.bg1 nav.nav-bg,
  body.bg2 nav.nav-bg {
    background-color: transparent !important;
    box-shadow: none !important;
  }

  nav .container {
    padding: 0 !important;
    gap: 1rem !important;
    background: transparent !important;
  }

  /* Hamburger button with its own background */
  .mobile-nav-toggle {
    background-color: inherit;
  }
  
  .mobile-nav-toggle,
  .back-btn {
    margin-left: max(0.75rem, env(safe-area-inset-left));
  }

  /* Theme switcher with its own background */
  #ini-mobile {
    margin-left: auto;
    margin-right: max(0.75rem, env(safe-area-inset-right));
    padding: 0.75rem !important;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  }

  label.group {
    transform: scale(1.2) !important;
  }

  #about,
  #contact {
    padding-left: max(1.5rem, env(safe-area-inset-left)) !important;
    padding-right: max(1.5rem, env(safe-area-inset-right)) !important;
  }
}

/* ==================== Background Themes ==================== */
.bg1 {
  background-image: url("lib/bg.webp");
}

.bg2 {
  background-image: url("lib/bg2.webp");
}

/* Hamburger colors based on theme */
body.bg1 .mobile-nav-toggle {
  background-color: #21E6C1;
}

body.bg1 .mobile-nav-toggle span {
  background-color: #071e3d;
}

body.bg2 .mobile-nav-toggle {
  background-color: #ffc800;
}

body.bg2 .mobile-nav-toggle span {
  background-color: #1f0701;
}

/* Back button theme integration */
.back-btn {
  display: inline-block;
  padding: 0.5rem;
  border-radius: 9999px;
  border-width: 1px;
  transition: all 300ms ease;
}

body.bg1 .back-btn {
  color: #21E6C1;
  border-color: #21E6C1;
  background-color: transparent;
}

body.bg1 .back-btn:hover {
  color: #071E3D;
  background-color: #21E6C1;
}

body.bg2 .back-btn {
  color: #ffc800;
  border-color: #ffc800;
  background-color: transparent;
}

body.bg2 .back-btn:hover {
  color: #1f0701;
  background-color: #ffc800;
}

/* Theme switcher background */
/* Removed block; mobile menu items styled individually above */

/* ==================== Layout Sections ==================== */
main {
  display: none;
  color: #030f1f;
}

nav {
  position: fixed;
  top: 1rem;
  left: 0;
  right: 0;
  margin-inline: auto;
  z-index: 9999;
  white-space: nowrap;
}

@media (min-width: 768px) {
  .desktop-nav-items {
    display: flex !important;
  }
}
/* ==================== Mobile Section Heights ==================== */
@media (max-width: 767px) {
  body {
    overflow-y: scroll;
  }

  /* Home section full height on mobile */
  section:first-of-type + section {
    min-height: 100vh !important;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* About section full height on mobile */
  #about {
    min-height: 100vh !important;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: 5rem !important;
    padding-bottom: 5rem !important;
  }

  #about > div {
    width: 100% !important;
    max-width: 100% !important;
    margin-top: 0 !important;
  }

  #about .text-right {
    text-align: center !important;
    width: 100% !important;
    margin-left: 0 !important;
  }

  /* Projects section adjustments */
  #projects {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }

  #projects > div {
    width: 100% !important;
    max-width: 100% !important;
    transform: scale(1) !important;
  }

  #projects h4 {
    text-align: center;
    margin-bottom: 2rem !important;
  }

  /* Contact section adjustments */
  #contact {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }

  #contact > div {
    width: 100% !important;
    max-width: 100% !important;
    transform: scale(1) !important;
  }

  #contact h4 {
    text-align: center;
  }

  /* Home text center on mobile */
  section:first-of-type + section > div {
    margin-left: auto !important;
    margin-right: auto !important;
    text-align: center;
  }

  section:first-of-type + section h4 {
    text-align: center;
  }
}

/* ==================== Tablet Adjustments ==================== */

/* ==================== Project Cards Responsive ==================== */
@media (max-width: 767px) {
  /* Arabic.html cards */
  .grid-cols-3 {
    grid-template-columns: repeat(1, minmax(0, 1fr)) !important;
  }

  article.project-card {
    width: 100% !important;
    max-width: 100% !important;
  }

  /* IT.html and Tahajji.html cards */
  .flex.gap-8 {
    flex-direction: column !important;
    gap: 1.5rem !important;
  }

  /* Scale adjustments */
  .scale-\[120\%\] {
    transform: scale(1) !important;
  }

  .scale-\[88\.5\%\] {
    transform: scale(1) !important;
  }

  .scale-\[85\%\] {
    transform: scale(1) !important;
  }
}

/* Tablet uses desktop layout */
@media (min-width: 768px) and (max-width: 1024px) {
  /* Home Projects: 2 columns tablet for 4 cards in 2 rows */
  #projects .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    grid-auto-rows: 1fr !important;
    gap: 1rem !important;
  }
  #projects article.project-card {
    grid-column: auto !important;
    grid-row: auto !important;
    width: 100% !important;
    max-width: 100% !important;
  }
}

/* ==================== Project Cards Theme ==================== */
.project-btn {
  transition: background-color 300ms ease, color 300ms ease;
}

body.bg2 .project-btn {
  background-color: #ffc800;
  color: #1f0701;
}

/* ==================== Contact Section Theme ==================== */
.contact-btn {
  transition: all 300ms ease;
  cursor: pointer;
}

.contact-btn:disabled {
  cursor: not-allowed;
}

.contact-btn.submitting {
  opacity: 0.6;
  cursor: not-allowed;
}

.contact-btn.success {
  background-color: #10b981 !important;
  opacity: 1;
}

.contact-btn.error {
  background-color: #ef4444 !important;
  opacity: 1;
}

body.bg2 .contact-btn {
  background-color: #ffc800;
  color: #1f0701;
}

body.bg2 .contact-btn.success {
  background-color: #10b981 !important;
  color: #ffffff !important;
}

body.bg2 .contact-btn.error {
  background-color: #ef4444 !important;
  color: #ffffff !important;
}

/* Contact Icon Theme */
.contact-icon {
  transition: background-color 300ms ease;
}

body.bg2 .contact-icon {
  background-color: #ffc800;
}

/* Social Links Hover Theme */
.social-link {
  transition: all 300ms ease;
}

body.bg2 .social-link:hover {
  background-color: #ffc800;
  border-color: #ffc800;
}

body.bg2 .social-link:hover svg {
  color: #1f0701;
}

/* Form Focus Theme */
body.bg2 #contact input:focus,
body.bg2 #contact textarea:focus {
  border-color: #ffc800;
}




