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

:root {
  --bg: #0c0c0e;
  --bg-soft: #111115;
  --text: #e8e6e0;
  --text-muted: #bdbdbd;
  --text-dim: #8a8a8a;
  --accent: #9b7fe8;
  --accent-soft: #c4aff5;
  --accent-glow: rgba(155, 127, 232, 0.12);
  --border: rgba(255, 255, 255, 0.06);
  --font-display: "Playfair Display", Georgia, serif;
  --font-body: "EB Garamond", Georgia, serif;
  --font-arabic: "Noto Naskh Arabic", serif;
}

html {
  scroll-behavior: smooth;
}

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.75;
  min-height: 100vh;
  transition: opacity 0.25s ease;
}

body.no-scroll {
  overflow: hidden;
  position: fixed;
  width: 100%;
}

/* Arabic overrides */
html[lang="ar"] body {
  font-family: var(--font-arabic);
  font-size: 19px;
  line-height: 1.9;
}

html[lang="ar"] h1,
html[lang="ar"] .nav-name,
html[lang="ar"] .product-title,
html[lang="ar"] .project-name {
  font-family: var(--font-arabic);
  letter-spacing: 0;
}

html[lang="ar"] .wrapper {
  direction: rtl;
}
html[lang="ar"] .nav-links {
  /* Keep natural order, just align to the right */
  direction: rtl;
}
html[lang="ar"] .project-item {
  direction: rtl;
}
html[lang="ar"] .contact-grid {
  direction: rtl;
}
html[lang="ar"] .stack {
  direction: rtl;
}
html[lang="ar"] .footer-links {
  /* Keep natural order, just align to the right */
  direction: rtl;
}
html[lang="ar"] .product-actions {
  direction: rtl;
}

/* Force LTR for phone numbers, emails, and URLs */
html[lang="ar"] .contact-value a[href^="tel:"],
html[lang="ar"] .contact-value a[href^="https://wa.me"],
html[lang="ar"] .contact-value a[href^="mailto:"],
html[lang="ar"] .contact-value a[href^="http"],
html[lang="ar"] .contact-value a[href^="https://"] {
  direction: ltr;
  display: inline-block;
  unicode-bidi: embed;
}

/* Force LTR for all links in footer */
html[lang="ar"] .footer-links a {
  direction: ltr;
  unicode-bidi: embed;
}

/* Ensure project tags stay in natural order */
html[lang="ar"] .project-tags {
  direction: ltr;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 1;
  opacity: 0.4;
}

.wrapper {
  max-width: 640px;
  margin: 0 auto;
  padding: 80px 28px 120px;
}

/* Nav */
nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 72px;
  opacity: 0;
  animation: fadeUp 0.6s ease forwards;
  position: relative;
  z-index: 1001;
}

.nav-name {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 500;
  color: var(--text);
  letter-spacing: 0.01em;
  position: relative;
  z-index: 1001;
}

.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  position: relative;
  z-index: 1001;
  transition: all 0.3s ease;
}

.hamburger span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--text-muted);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 2px;
  transform-origin: center;
}

.hamburger:hover span {
  background: var(--accent-soft);
}

.hamburger.active {
  z-index: 1001;
}

.hamburger.active span {
  background: var(--text);
}

.hamburger.active span:nth-child(1) {
  transform: rotate(45deg) translate(6px, 6px);
}

.hamburger.active span:nth-child(2) {
  opacity: 0;
  transform: translateX(-10px);
}

.hamburger.active span:nth-child(3) {
  transform: rotate(-45deg) translate(6px, -6px);
}

.nav-links {
  display: flex;
  gap: 24px;
  list-style: none;
  align-items: center;
}

.nav-links a {
  font-size: 0.9rem;
  color: var(--text-muted);
  text-decoration: none;
  letter-spacing: 0.03em;
  transition: color 0.2s;
  border-bottom: none;
}

.nav-links a:hover {
  color: var(--text);
  border-bottom: none;
}

.nav-cv-btn {
  font-size: 0.8rem !important;
  padding: 5px 14px;
  border-radius: 100px;
  border: 1px solid var(--border) !important;
  color: var(--text-muted) !important;
  background: var(--bg-soft);
  text-decoration: none;
  transition: all 0.2s !important;
  letter-spacing: 0.04em;
}

.nav-cv-btn:hover {
  border-color: var(--accent) !important;
  color: var(--accent-soft) !important;
}

/* Main */
main {
  opacity: 0;
  animation: fadeUp 0.6s ease 0.15s forwards;
}

h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 2.6rem);
  font-weight: 400;
  line-height: 1.2;
  margin-bottom: 28px;
  color: var(--text);
  letter-spacing: -0.01em;
}

html[lang="ar"] h1 {
  line-height: 1.4;
}

h1 em {
  font-style: italic;
  color: var(--accent-soft);
}

p {
  color: var(--text);
  margin-bottom: 20px;
  font-size: 1.05rem;
}

p:last-of-type {
  margin-bottom: 0;
}

a {
  color: var(--accent-soft);
  text-decoration: underline;
  text-decoration-color: rgba(196, 175, 245, 0.4);
  text-underline-offset: 2px;
  transition:
    text-decoration-color 0.2s,
    color 0.2s;
}

a:hover {
  color: #fff;
  text-decoration-color: var(--accent);
}

.highlight-text {
  color: var(--accent-soft);
  border-bottom: 1px solid transparent;
  transition:
    border-color 0.2s,
    color 0.2s;
  cursor: default;
  text-decoration: underline;
  text-decoration-color: rgba(196, 175, 245, 0.3);
  text-underline-offset: 2px;
}

.highlight-text:hover {
  color: #fff;
  text-decoration-color: var(--accent);
}

/* Sections */
section {
  margin-top: 64px;
  padding-top: 48px;
  border-top: 1px solid var(--border);
  opacity: 0;
  animation: fadeUp 0.6s ease forwards;
}

section:nth-of-type(1) {
  animation-delay: 0.25s;
}
section:nth-of-type(2) {
  animation-delay: 0.35s;
}
section:nth-of-type(3) {
  animation-delay: 0.45s;
}
section:nth-of-type(4) {
  animation-delay: 0.55s;
}

.section-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-dim);
  margin-bottom: 24px;
}

html[lang="ar"] .section-label {
  letter-spacing: 0;
}

/* Project list */
.project-list {
  list-style: none;
  display: flex;
  flex-direction: column;
}

.project-item {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: 16px;
  padding: 18px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.2s;
  border-radius: 8px;
  margin: 0 -12px;
  padding-left: 12px;
  padding-right: 12px;
}

.project-item:last-child {
  border-bottom: none;
}

/* Desktop hover effects */
@media (hover: hover) and (pointer: fine) {
  .project-item:hover {
    background: var(--bg-soft);
    border-color: rgba(155, 127, 232, 0.15);
  }

  .project-item:hover .project-name {
    color: var(--accent-soft);
  }

  .project-item:hover .project-desc {
    color: var(--text);
  }

  .project-item:hover .project-tag {
    border-color: var(--accent-soft);
    color: var(--text-muted);
  }

  .project-item:hover .project-arrow {
    opacity: 1;
    transform: translate(2px, -2px);
  }

  html[lang="ar"] .project-item:hover .project-arrow {
    transform: translate(-2px, -2px);
  }
}

/* Mobile tap/active effects */
@media (hover: none) and (pointer: coarse) {
  .project-item:active {
    background: var(--bg-soft);
    border-color: rgba(155, 127, 232, 0.15);
  }

  .project-item:active .project-name {
    color: var(--accent-soft);
  }

  .project-arrow {
    opacity: 0.5;
  }
}

.project-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.project-name {
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--text);
  font-weight: 400;
  transition: color 0.2s;
}

.project-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-style: italic;
  transition: color 0.2s;
}

html[lang="ar"] .project-desc {
  font-style: normal;
}

.project-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.project-tag {
  font-size: 0.75rem;
  padding: 2px 9px;
  border-radius: 100px;
  border: 1px solid var(--border);
  color: var(--text-dim);
  transition: all 0.2s;
}

.project-arrow {
  font-size: 0.9rem;
  color: var(--text-dim);
  opacity: 0;
  transition: all 0.2s;
  margin-top: 4px;
}

/* Stack pills */
.stack {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 20px;
}

.stack-pill {
  font-size: 0.8rem;
  padding: 4px 12px;
  border-radius: 100px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  background: var(--bg-soft);
  font-family: "Georgia", serif;
  letter-spacing: 0.02em;
  transition: all 0.2s;
  cursor: default;
}

.stack-pill:hover {
  border-color: var(--accent);
  color: var(--accent-soft);
}

/* CV download */
.cv-download {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 24px;
  font-size: 0.9rem;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 16px;
  background: var(--bg-soft);
  text-decoration: none;
  transition: all 0.2s;
}

.cv-download:hover {
  border-color: var(--accent);
  color: var(--accent-soft) !important;
  border-bottom: 1px solid var(--accent) !important;
}

/* Product card */
.product-card {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 32px;
  position: relative;
  overflow: hidden;
}

.product-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(
    ellipse at top left,
    var(--accent-glow),
    transparent 65%
  );
  pointer-events: none;
}

html[lang="ar"] .product-card::before {
  background: radial-gradient(
    ellipse at top right,
    var(--accent-glow),
    transparent 65%
  );
}

.product-badge {
  display: inline-block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 3px 10px;
  border-radius: 100px;
  background: rgba(155, 127, 232, 0.15);
  color: var(--accent-soft);
  border: 1px solid rgba(155, 127, 232, 0.25);
  margin-bottom: 16px;
}

html[lang="ar"] .product-badge {
  letter-spacing: 0;
}

.product-title {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 400;
  font-style: italic;
  color: var(--text);
  margin-bottom: 12px;
}

.product-desc {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 20px;
  line-height: 1.7;
}

.product-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 20px;
}

.product-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 6px;
  padding: 10px 22px;
  font-family: var(--font-body);
  font-size: 0.92rem;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
}

.product-cta-primary {
  background: var(--accent);
  color: #fff !important;
}

.product-cta-primary:hover {
  background: var(--accent-soft);
  color: #0c0c0e !important;
  transform: translateY(-1px);
}

.product-cta-secondary {
  background: transparent;
  color: var(--accent-soft) !important;
  border: 1px solid var(--accent);
}

.product-cta-secondary:hover {
  background: rgba(155, 127, 232, 0.1);
  color: #fff !important;
  transform: translateY(-1px);
}

/* Contact grid */
.contact-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 8px;
}

.contact-item {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 18px;
  transition: border-color 0.2s;
}

.contact-item:hover {
  border-color: rgba(155, 127, 232, 0.3);
}

.contact-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  margin-bottom: 4px;
}

html[lang="ar"] .contact-label {
  letter-spacing: 0;
}

.contact-value {
  font-size: 0.9rem;
}

.contact-value a {
  color: var(--accent-soft);
  border-bottom: none;
}

.contact-value a:hover {
  color: #fff;
  border-bottom: none;
}

/* Footer */
footer {
  margin-top: 80px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  opacity: 0;
  animation: fadeUp 0.6s ease 0.65s forwards;
}

.footer-copy {
  font-size: 0.82rem;
  color: var(--text-dim);
  font-style: italic;
}

html[lang="ar"] .footer-copy {
  font-style: normal;
}

.footer-links {
  display: flex;
  gap: 20px;
}

.footer-links a {
  font-size: 0.82rem;
  color: var(--text-dim);
  border-bottom: none;
  transition: color 0.2s;
}

.footer-links a:hover {
  color: var(--accent-soft);
}

/* Cursor dot */
.cursor-dot {
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  position: fixed;
  pointer-events: none;
  z-index: 9999;
  transform: translate(-50%, -50%);
  transition:
    transform 0.15s ease,
    opacity 0.15s ease;
  mix-blend-mode: screen;
}

/* Language switcher (floating) */
.lang-switcher {
  position: fixed;
  bottom: 32px;
  right: 32px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  z-index: 1002;
}

html[lang="ar"] .lang-switcher {
  right: auto;
  left: 32px;
  align-items: flex-start;
}

.lang-toggle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-family: var(--font-body);
  letter-spacing: 0.04em;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

.lang-toggle:hover {
  border-color: var(--accent);
  color: var(--accent-soft);
}

.lang-toggle {
  box-shadow:
    0 4px 24px rgba(0, 0, 0, 0.6),
    0 0 12px var(--accent-glow);
}

.lang-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
}

.lang-options.open {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0);
}

.lang-btn {
  padding: 6px 14px;
  border-radius: 100px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  text-align: center;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

.lang-btn:hover {
  border-color: var(--accent);
  color: var(--accent-soft);
}

.lang-btn.active {
  border-color: var(--accent);
  color: var(--accent-soft);
  background: rgba(155, 127, 232, 0.08);
}

/* Page transition */
body.fading {
  opacity: 0;
}

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

::-webkit-scrollbar {
  width: 4px;
}
::-webkit-scrollbar-track {
  background: var(--bg);
}
::-webkit-scrollbar-thumb {
  background: var(--text-dim);
  border-radius: 2px;
}

@media (max-width: 768px) {
  .hamburger {
    display: flex;
  }

  .nav-links {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: 60%;
    max-width: 320px;
    background: rgba(17, 17, 21, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-left: 1px solid var(--border);
    flex-direction: column;
    align-items: flex-start;
    padding: 80px 32px 32px;
    gap: 20px;
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
  }

  html[lang="ar"] .nav-links {
    right: auto;
    left: 0;
    border-left: none;
    border-right: 1px solid var(--border);
    transform: translateX(-100%);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
  }

  .nav-links.active {
    transform: translateX(0);
  }

  .nav-links li {
    width: 100%;
  }

  .nav-links a {
    display: block;
    width: 100%;
    padding: 8px 0;
    font-size: 1.1rem;
    color: var(--text);
  }

  .nav-cv-btn {
    width: 100%;
    text-align: center;
    margin-top: 12px;
    background: var(--bg);
  }

  .project-tag {
    color: var(--text-muted);
  }
}

@media (max-width: 540px) {
  .wrapper {
    padding: 48px 20px 80px;
    overflow-x: hidden;
  }

  nav {
    margin-bottom: 48px;
    flex-wrap: nowrap;
  }

  .hamburger {
    display: flex;
  }

  .nav-links {
    position: fixed;
    top: 0;
    right: -28px;
    height: 100vh;
    width: 70%;
    max-width: 300px;
    background: var(--bg-soft);
    border-left: 1px solid var(--border);
    flex-direction: column;
    align-items: flex-start;
    padding: 80px 28px 28px;
    gap: 20px;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    z-index: 1000;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.4);
  }

  html[lang="ar"] .nav-links {
    right: auto;
    left: 0;
    border-left: none;
    border-right: 1px solid var(--border);
    transform: translateX(-100%);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
  }

  .nav-links.active {
    transform: translateX(0);
  }

  .nav-links li {
    width: 100%;
  }

  .nav-links a {
    display: block;
    width: 100%;
    padding: 8px 0;
    font-size: 1rem;
  }

  .nav-cv-btn {
    width: 100%;
    text-align: center;
    margin-top: 12px;
  }

  .contact-grid {
    grid-template-columns: 1fr;
  }
  footer {
    flex-direction: column;
    gap: 12px;
    text-align: center;
  }
  .cursor-dot {
    display: none;
  }
  .lang-switcher {
    bottom: 20px;
    right: 20px;
  }
  html[lang="ar"] .lang-switcher {
    left: 20px;
    right: auto;
  }
}
