/* =====================================================
   Preloader, language switch, mobile menu, work section, RTL
   ===================================================== */

/* ---------- Preloader ---------- */
.loader {
  position: fixed; inset: 0; z-index: 200; background: var(--bg);
  display: grid; place-content: center; justify-items: center; gap: 18px;
  transition: transform .9s var(--ease) .1s, opacity .4s ease .7s;
}
body.is-loaded .loader { transform: translateY(-100%); opacity: 0; pointer-events: none; }
.loader__mark svg { width: 110px; height: 110px; }
.loader__rect { stroke-dasharray: 420; stroke-dashoffset: 420; animation: draw 1.2s var(--ease) forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.loader__aa { font-family: var(--display); font-weight: 700; font-size: 40px; fill: #fff; opacity: 0; animation: fadeUp .6s var(--ease) .4s forwards; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.loader__count { font-family: var(--mono); font-size: 13px; color: var(--muted); letter-spacing: .1em; }
body.is-loading { overflow: hidden; }

/* ---------- Nav right side ---------- */
.nav__right { display: flex; align-items: center; gap: 8px; }
.nav.is-scrolled { background: rgba(12,18,32,.82); }
.lang {
  height: 40px; padding: 0 4px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255,255,255,.03);
  display: flex; align-items: center; gap: 2px; cursor: pointer; color: var(--muted); font: 600 13px var(--display);
}
.lang span { padding: 5px 8px; border-radius: 8px; transition: background .25s, color .25s; }
.lang__ar { font-family: "Readex Pro", var(--display); }
html[lang="en"] .lang__en, html[lang="ar"] .lang__ar { background: var(--grad); color: #fff; }
.lang:hover { border-color: var(--blue); }

.burger { display: none; width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255,255,255,.03); cursor: pointer; position: relative; }
.burger i { position: absolute; left: 12px; right: 12px; height: 2px; border-radius: 2px; background: var(--ink); transition: transform .35s var(--ease), top .35s var(--ease); }
.burger i:first-child { top: 16px; }
.burger i:last-child { top: 24px; }
.menu-open .burger i:first-child { top: 20px; transform: rotate(45deg); }
.menu-open .burger i:last-child { top: 20px; transform: rotate(-45deg); }

/* ---------- Mobile menu ---------- */
.menu {
  position: fixed; inset: 0; z-index: 45; background: rgba(6,10,18,.96);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  display: flex; flex-direction: column; justify-content: center; padding: 100px 28px 40px;
  clip-path: circle(0% at calc(100% - 40px) 40px); transition: clip-path .7s var(--ease), visibility 0s linear .7s;
  visibility: hidden;
}
html[dir="rtl"] .menu { clip-path: circle(0% at 40px 40px); }
.menu-open .menu { clip-path: circle(150% at calc(100% - 40px) 40px); visibility: visible; transition: clip-path .7s var(--ease); }
html[dir="rtl"] .menu-open .menu { clip-path: circle(150% at 40px 40px); }
.menu nav { display: grid; gap: 6px; }
.menu nav a {
  display: flex; align-items: baseline; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--line);
  opacity: 0; transform: translateY(20px); transition: opacity .5s, transform .5s var(--ease);
}
.menu-open .menu nav a { opacity: 1; transform: none; }
.menu-open .menu nav a:nth-child(1) { transition-delay: .15s; }
.menu-open .menu nav a:nth-child(2) { transition-delay: .2s; }
.menu-open .menu nav a:nth-child(3) { transition-delay: .25s; }
.menu-open .menu nav a:nth-child(4) { transition-delay: .3s; }
.menu-open .menu nav a:nth-child(5) { transition-delay: .35s; }
.menu nav span { font-family: var(--mono); font-size: 12px; color: #8fb1ff; }
.menu nav b { font-family: var(--display); font-size: 36px; font-weight: 600; letter-spacing: -.03em; }
.menu__insta { margin-top: 28px; color: var(--muted); font-family: var(--mono); font-size: 14px; }
body.menu-open { overflow: hidden; }

/* ---------- Work with me ---------- */
.work { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.work__card {
  display: flex; flex-direction: column; gap: 10px; padding: 24px; min-height: 260px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  transition: transform .45s var(--ease), opacity .9s var(--ease), background .3s;
}
.work__card.is-in:hover { transform: translateY(-6px); background: var(--surface-2); }
.work__icon { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; background: rgba(61,123,255,.12); border: 1px solid rgba(61,123,255,.3); margin-bottom: 8px; transition: transform .4s var(--ease); }
.work__card:hover .work__icon { transform: rotate(-8deg) scale(1.06); }
.work__icon svg { width: 22px; height: 22px; fill: none; stroke: var(--cyan); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.work__card h3 { font-size: 21px; font-weight: 600; }
.work__card p { margin: 0; color: var(--muted); font-size: 15px; flex: 1; }
.work__go { display: inline-flex; align-items: center; gap: 6px; font-family: var(--display); font-weight: 500; color: var(--ink-2); margin-top: 8px; }
.work__go svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .3s var(--ease); }
.work__card:hover .work__go { color: var(--cyan); }
.work__card:hover .work__go svg { transform: translateX(4px); }

/* ---------- Language switch fade ---------- */
main, .nav__links, .footer { transition: opacity .22s ease; }
body.lang-switching main, body.lang-switching .nav__links, body.lang-switching .footer { opacity: 0; }

/* ---------- Arabic / RTL ---------- */
html[lang="ar"] body { font-family: "IBM Plex Sans Arabic", var(--body); }
html[lang="ar"] h1, html[lang="ar"] h2, html[lang="ar"] h3,
html[lang="ar"] .btn, html[lang="ar"] .nav__name, html[lang="ar"] .nav__links a,
html[lang="ar"] .menu nav b, html[lang="ar"] .venture__link, html[lang="ar"] .work__go {
  font-family: "Readex Pro", var(--display); letter-spacing: 0;
}
html[lang="ar"] .hero__title { line-height: 1.25; font-size: clamp(36px, 5vw, 66px); }
html[lang="ar"] .head h2, html[lang="ar"] .skills__intro h2, html[lang="ar"] .contact h2 { line-height: 1.25; }
html[lang="ar"] .kicker, html[lang="ar"] .label { font-family: "IBM Plex Sans Arabic", var(--mono); letter-spacing: 0; }
html[lang="ar"] [data-split] .w { padding-bottom: .2em; margin-bottom: -.2em; }
html[dir="rtl"] .arr, html[dir="rtl"] .venture__link svg { transform: scaleX(-1); }
html[dir="rtl"] .btn:hover .arr, html[dir="rtl"] .work__card:hover .work__go svg { transform: scaleX(-1) translateX(4px); }
html[dir="rtl"] .venture:hover .venture__link svg { transform: scaleX(-1) translate(3px, -3px); }
html[dir="rtl"] .kicker__caret { margin-left: 0; margin-right: 2px; }
html[dir="rtl"] .stampcard { direction: ltr; }
html[dir="rtl"] .skill__n { right: auto; left: 22px; }
html[dir="rtl"] .journey::after { transform-origin: right; }
html[dir="rtl"] .journey li::before { left: auto; right: 22px; }
html[dir="rtl"] .skill.reveal.is-in:hover { transform: translateX(-6px); }
html[dir="rtl"] .float--1 { left: auto; right: -9%; }
html[dir="rtl"] .float--2 { right: auto; left: -14%; }
html[dir="rtl"] .float--3 { left: auto; right: -11%; }
html[dir="rtl"] .ticker__track { direction: ltr; }
html[dir="rtl"] .nav { padding: 8px 10px 8px 8px; }

/* ---------- Responsive additions ---------- */
@media (max-width: 1080px) {
  .work { grid-template-columns: 1fr 1fr; }
  html[dir="rtl"] .float--1 { right: -8%; }
  html[dir="rtl"] .float--2 { left: -6%; }
  html[dir="rtl"] .float--3 { right: -4%; }
}
@media (max-width: 860px) {
  .burger { display: block; }
  .nav__cta { display: none; }
}
@media (max-width: 600px) {
  .work { grid-template-columns: 1fr; }
  .work__card { min-height: 0; }
  html[dir="rtl"] .float--1 { right: -4px; left: auto; }
  html[dir="rtl"] .float--2 { left: -4px; right: auto; }
  html[dir="rtl"] .float--3 { right: -4px; left: auto; }
}
@media (prefers-reduced-motion: reduce) {
  .loader { display: none; }
  .menu { transition: none; }
}
html[lang="ar"] .journey__when, html[lang="ar"] .menu nav span { font-family: "IBM Plex Sans Arabic", var(--mono); }
html[dir="rtl"] .menu__insta { align-self: flex-end; }

/* ---------- Rotating roles ---------- */
.roles { margin: 22px 0 0; font-family: var(--display); font-size: clamp(20px, 2vw, 26px); font-weight: 500; color: var(--muted); display: flex; align-items: baseline; gap: .35em; flex-wrap: wrap; }
.rotator { position: relative; display: inline-grid; overflow: hidden; height: 1.35em; vertical-align: bottom; min-width: 10ch; }
.rotator__word {
  grid-area: 1 / 1; white-space: nowrap; color: #6fd9f5;
  transform: translateY(100%); opacity: 0; transition: transform .55s var(--ease), opacity .55s var(--ease);
}
.rotator__word.is-on { transform: none; opacity: 1; }
.rotator__word.is-out { transform: translateY(-100%); opacity: 0; }
.rotator::after { content: ""; position: absolute; left: 0; right: 0; bottom: 2px; height: 2px; background: var(--grad); opacity: .5; border-radius: 2px; }
html[lang="ar"] .roles { font-family: "Readex Pro", var(--display); }
html[lang="ar"] .rotator { height: 1.6em; }
