/* ============ THEME TOKENS (RGB channels, lerped by JS) ============ */
:root {
  --bg: 10,10,15;
  --bg2: 10,10,15;
  --soft: 18,21,32;
  --text: 243,244,246;
  --muted: 156,163,175;
  --br: 255,255,255;
  --acc: 220,38,38;
  --acc2: 185,28,28;
  --glow: 239,68,68;
  --btntext: 255,255,255;
}

/* ============ BASE ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 76px; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: linear-gradient(180deg, rgba(var(--bg),1) 0%, rgba(var(--bg2),1) 100%);
  color: rgba(var(--text),1);
  overflow-x: hidden;
  transition: background 0.4s ease, color 0.4s ease;
  min-height: 100vh;
}

::selection { background: rgba(var(--acc),0.35); color: #fff; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: rgba(var(--bg),1); }
::-webkit-scrollbar-thumb { background: rgba(var(--br),0.16); border-radius: 5px; border: 2px solid rgba(var(--bg),1); }
::-webkit-scrollbar-thumb:hover { background: rgba(var(--acc),0.9); }

.glow {
  position: fixed;
  inset: 0 auto auto 0;
  width: 100%;
  height: 62vh;
  pointer-events: none;
  z-index: 0;
  background: radial-gradient(ellipse 72% 62% at 50% -12%, rgba(var(--glow),0.14), transparent 72%);
  transition: background 0.4s ease;
}

main { position: relative; z-index: 1; }

a { color: inherit; text-decoration: none; }

/* ============ NAV ============ */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px clamp(20px, 5vw, 48px);
  background: rgba(var(--bg),0.6);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(var(--br),0.08);
  transition: background 0.4s ease;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 1.02rem;
  letter-spacing: 0.5px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 28px; height: 28px;
  border-radius: 8px;
  background: rgba(var(--acc),1);
  color: #fff;
  font-size: 0.92rem;
  font-weight: 800;
  transition: background 0.4s ease;
}

.nav-links { display: flex; gap: 4px; align-items: center; }

.nav-links a {
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 500;
  font-family: 'JetBrains Mono', monospace;
  color: rgba(var(--muted),1);
  transition: color 0.18s ease, background 0.18s ease;
}

.nav-links a:hover {
  color: rgba(var(--text),1);
  background: rgba(var(--br),0.06);
}

/* ============ LANGUAGE SWITCH ============ */
.lang-switch {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: rgba(var(--br),0.06);
  border: 1px solid rgba(var(--br),0.1);
}

.lang-switch button {
  border: 0;
  background: transparent;
  color: rgba(var(--muted),1);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.18s ease, background 0.18s ease;
}

.lang-switch button:hover { color: rgba(var(--text),1); }

.lang-switch button.active {
  background: rgba(var(--acc),1);
  color: rgba(var(--btntext),1);
}

/* ============ RTL / ARABIC ============ */
html[lang="ar"] body { font-family: 'Tajawal', 'Inter', system-ui, sans-serif; }

html[dir="rtl"] .feats li { padding-left: 0; padding-right: 22px; }
html[dir="rtl"] .feats li::before { left: auto; right: 0; }
html[dir="rtl"] .caret { margin-left: 0; margin-right: 5px; }
html[dir="rtl"] svg[stroke] { transform: scaleX(-1); }

/* ============ HERO ============ */
.hero {
  max-width: 1100px;
  margin: 0 auto;
  padding: clamp(130px, 19vh, 190px) clamp(24px, 5vw, 48px) 40px;
}

.eyebrow {
  font-size: 0.92rem;
  color: rgba(var(--muted),1);
  margin-bottom: 22px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.eyebrow b { color: rgba(var(--text),1); font-weight: 600; }

.pill {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: rgba(var(--acc),1);
  background: rgba(var(--acc),0.12);
  border: 1px solid rgba(var(--acc),0.3);
  border-radius: 999px;
  padding: 3px 10px;
  transition: color 0.4s ease, background 0.4s ease, border-color 0.4s ease;
}

.hero h1 {
  font-size: clamp(2.3rem, 6.4vw, 4.1rem);
  font-weight: 800;
  line-height: 1.06;
  letter-spacing: -0.02em;
}

.type { color: rgba(var(--acc),1); transition: color 0.4s ease; }

.caret {
  display: inline-block;
  width: 3px;
  height: 0.82em;
  margin-left: 5px;
  vertical-align: -0.06em;
  background: rgba(var(--acc),1);
  animation: blink 1.1s steps(2, start) infinite;
  transition: background 0.4s ease;
}

@keyframes blink { to { visibility: hidden; } }

.hero-sub {
  margin-top: 22px;
  max-width: 620px;
  font-size: 1.06rem;
  line-height: 1.7;
  color: rgba(var(--muted),1);
}

.hero-cta { margin-top: 34px; display: flex; gap: 14px; flex-wrap: wrap; }

.stats {
  margin-top: 56px;
  display: flex;
  gap: clamp(32px, 6vw, 72px);
  flex-wrap: wrap;
}

.stats b {
  display: block;
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: rgba(var(--text),1);
}

.stats span {
  display: block;
  margin-top: 3px;
  font-size: 0.8rem;
  color: rgba(var(--muted),1);
}

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.btn svg { width: 16px; height: 16px; }

.btn.primary {
  background: rgba(var(--acc),1);
  color: rgba(var(--btntext),1);
}

.btn.primary:hover {
  background: rgba(var(--acc2),1);
  box-shadow: 0 8px 26px rgba(var(--glow),0.25);
  transform: translateY(-1px);
}

.btn.ghost {
  background: rgba(var(--br),0.05);
  color: rgba(var(--text),1);
  border-color: rgba(var(--br),0.16);
}

.btn.ghost:hover {
  background: rgba(var(--br),0.1);
  border-color: rgba(var(--br),0.28);
  transform: translateY(-1px);
}

/* ============ WORK SECTIONS ============ */
.work {
  max-width: 1100px;
  margin: 0 auto;
  padding: clamp(70px, 10vh, 110px) clamp(24px, 5vw, 48px);
  display: grid;
  grid-template-columns: minmax(300px, 1fr) 1.25fr;
  gap: clamp(28px, 5vw, 56px);
  align-items: center;
}

.work-head { display: flex; flex-direction: column; }

.work.alt .work-head { order: 2; }
.work.alt .panel { order: 1; }

.idx {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: rgba(var(--acc),1);
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  transition: color 0.4s ease;
}

.idx::after {
  content: '';
  width: 44px;
  height: 1px;
  background: rgba(var(--br),0.22);
}

.work h2 {
  font-size: clamp(1.7rem, 3vw, 2.2rem);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.desc {
  margin-top: 12px;
  font-size: 0.98rem;
  line-height: 1.65;
  color: rgba(var(--muted),1);
}

.feats { list-style: none; margin-top: 20px; display: grid; gap: 10px; }

.feats li {
  position: relative;
  padding-left: 22px;
  font-size: 0.9rem;
  color: rgba(var(--muted),1);
  line-height: 1.5;
}

.feats li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: rgba(var(--acc),1);
  opacity: 0.85;
  transition: background 0.4s ease;
}

.work-cta { margin-top: 28px; display: flex; gap: 12px; flex-wrap: wrap; }

/* ============ PROJECT PANEL (themed, no iframe) ============ */
.panel {
  position: relative;
  display: flex;
  flex-direction: column;
  background: rgba(var(--soft),0.55);
  border: 1px solid rgba(var(--br),0.12);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 30px 60px rgba(0,0,0,0.35);
  transition: background 0.4s ease, border-color 0.4s ease;
  min-height: clamp(280px, 34vw, 360px);
}

.panel:hover {
  transform: translateY(-3px);
  box-shadow: 0 36px 72px rgba(0,0,0,0.45), 0 0 0 1px rgba(var(--acc),0.22);
}

.panel-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 11px 14px;
  border-bottom: 1px solid rgba(var(--br),0.08);
}

.panel-bar span {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: rgba(var(--br),0.15);
}

.panel-bar i {
  margin-left: 10px;
  font-style: normal;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  color: rgba(var(--muted),1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-radius: 999px;
  padding: 3px 10px;
  background: rgba(var(--br),0.05);
}

.panel-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 14px;
  padding: 30px;
  position: relative;
  background:
    radial-gradient(ellipse 90% 70% at 50% 120%, rgba(var(--pc),0.20), transparent 70%),
    linear-gradient(160deg, rgba(var(--pc2),0.22), rgba(var(--bg2),0.2));
  background-color: rgba(var(--bg),0.35);
}

.p-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(var(--pc),1);
  border: 1px solid rgba(var(--pc),0.35);
  border-radius: 999px;
  padding: 4px 12px;
}

.p-glyph {
  width: 74px; height: 74px;
  color: rgba(var(--pc),0.95);
  filter: drop-shadow(0 10px 22px rgba(var(--pc),0.35));
}

.p-name {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.p-line {
  width: 40px;
  height: 3px;
  border-radius: 3px;
  background: rgba(var(--pc),1);
  opacity: 0.85;
}

.p-meta {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.76rem;
  color: rgba(var(--muted),1);
}

/* ============ LIVE EMBED PANEL (real app preview) ============ */
.panel.embed .panel-body {
  display: block;
  padding: 0;
  background: rgba(var(--bg),0.5);
}

.panel.embed .iframe-wrap {
  position: relative;
  width: 100%;
  height: clamp(360px, 52vh, 520px);
  overflow: hidden;
  background: repeating-linear-gradient(45deg, rgba(var(--br),0.02), rgba(var(--br),0.02) 10px, rgba(var(--br),0.05) 10px, rgba(var(--br),0.05) 20px);
}

.panel.embed iframe.embed-frame {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: #0b0d10;
  opacity: 0;
  transition: opacity 0.5s ease;
}

.panel.embed iframe.embed-frame.loaded { opacity: 1; }

.panel.embed .embed-load {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.76rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(var(--muted),1);
  animation: pulse 1.6s ease-in-out infinite;
  pointer-events: none;
}

.panel.embed .embed-load::before {
  content: '';
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(var(--br),0.15);
  border-top-color: rgba(var(--acc),1);
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.panel-bar a.url {
  margin-left: 10px;
  font-style: normal;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  color: rgba(var(--muted),1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-radius: 999px;
  padding: 3px 10px;
  background: rgba(var(--br),0.05);
  transition: color 0.18s ease, background 0.18s ease;
  display: block;
  flex: 1;
}

.panel-bar a.url:hover { color: rgba(var(--text),1); background: rgba(var(--br),0.12); }

/* ============ GITHUB SECTION ============ */
.github {
  max-width: 1100px;
  margin: 0 auto;
  padding: clamp(70px, 10vh, 110px) clamp(24px, 5vw, 48px) 30px;
}

.gh-card {
  display: flex;
  gap: clamp(18px, 3vw, 28px);
  align-items: center;
  padding: 26px;
  border-radius: 18px;
  background: rgba(var(--soft),0.55);
  border: 1px solid rgba(var(--br),0.1);
  transition: background 0.4s ease, border-color 0.4s ease;
}

.avatar {
  width: 72px; height: 72px;
  border-radius: 50%;
  border: 2px solid rgba(var(--acc),0.6);
  flex-shrink: 0;
  background: rgba(var(--br),0.08);
  transition: border-color 0.4s ease;
}

.gh-info h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: clamp(1.4rem, 2.4vw, 1.8rem);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.gh-info p {
  margin-top: 8px;
  font-size: 0.94rem;
  line-height: 1.65;
  color: rgba(var(--muted),1);
  max-width: 640px;
}

.gh-info .btn { margin-top: 18px; }

/* ============ FOOTER ============ */
footer {
  max-width: 1100px;
  margin: 0 auto;
  padding: 34px clamp(24px, 5vw, 48px) 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  border-top: 1px solid rgba(var(--br),0.08);
  margin-top: 60px;
}

footer p { font-size: 0.84rem; color: rgba(var(--muted),1); }

.foot-links { display: flex; gap: 22px; }

.foot-links a { font-size: 0.84rem; font-weight: 500; color: rgba(var(--muted),1); transition: color 0.18s ease; }

.foot-links a:hover { color: rgba(var(--acc),1); }

/* ============ SCROLL REVEAL (gated behind html.js) ============ */
/* If JS never runs, html.js is absent and everything stays visible. */
html.js .reveal {
  opacity: 0;
  transform: translateY(26px);
  transition: opacity 0.7s cubic-bezier(0.22, 1, 0.36, 1), transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: opacity, transform;
}

html.js .reveal.in {
  opacity: 1;
  transform: none;
}

/* Left/right slide variants used on alt work sections */
html.js .reveal.left { transform: translateX(-30px); }
html.js .reveal.right { transform: translateX(30px); }
html.js .reveal.left.in, html.js .reveal.right.in { transform: none; }

/* Stagger the two columns of each work section (reveal-in only) */
html.js .work .in.work-head { transition-delay: 0.05s; }
html.js .work .reveal.in.panel { transition-delay: 0.15s; }

/* ============ RESPONSIVE ============ */
@media (max-width: 860px) {
  .work { grid-template-columns: 1fr; }
  .work.alt .work-head { order: 1; }
  .nav-links a { padding: 7px 9px; font-size: 0.76rem; }
  .gh-card { flex-direction: column; text-align: center; align-items: center; }
  .gh-info p { max-width: 100%; }
  .panel { min-height: 260px; }
}

@media (max-width: 560px) {
  .nav-links { display: none; }
  .brand { font-size: 0.9rem; }
  .hero h1 { font-size: 2.1rem; }
  .stats { gap: 26px; }
  .panel-body { padding: 22px; }
}
