/* ==========================================================
   1. TOKENS
   ========================================================== */
:root {
  --bg: #0b0f19;
  --panel: rgba(17, 24, 39, .55);
  --blue: #2563eb;
  --cyan: #06b6d4;
  --violet: #8b5cf6;
  --accent: var(--cyan);
  --accent-hover: #67e8f9;
  --grad: linear-gradient(135deg, var(--blue), var(--cyan));
  --text: #f1f5f9;
  --muted: #94a3b8;
  --border: rgba(148, 163, 184, .16);
  --radius: 18px;
  --ease: cubic-bezier(.4, 0, .2, 1);
  --t: .3s var(--ease);
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Tahoma, Arial, sans-serif;
}

/* ==========================================================
   2. BASE
   ========================================================== */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font); line-height: 1.65; overflow-x: hidden;
  transition: opacity .2s ease;
}
body.switching { opacity: 0; }
body.lock { overflow: hidden; }
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent-hover); outline-offset: 3px; border-radius: 6px; }
main, .footer { position: relative; z-index: 1; }

/* Particle canvas sits behind everything */
#bg { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }

/* Gradient 1px border (used on cards, skill tags, modal) via masked ::after */
.glass { background: var(--panel); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); position: relative; }
.glass::after, .skills li::after, .filters button::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1px; pointer-events: none;
  background: linear-gradient(135deg, rgba(37, 99, 235, .6), rgba(255, 255, 255, .06) 45%, rgba(6, 182, 212, .5));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
}

/* ==========================================================
   3. HEADER (morphs into a compact glass pill on scroll)
   ========================================================== */
.site-header { position: sticky; top: 0; z-index: 20; padding: 0 .75rem; }
.nav {
  max-width: 1080px; margin: 0 auto; padding: .9rem 1.25rem; display: flex; align-items: center; gap: 1.5rem;
  border: 1px solid transparent; border-radius: 0;
  transition: max-width var(--t), padding var(--t), margin var(--t), border-radius var(--t), background var(--t), box-shadow var(--t), border-color var(--t);
}
.site-header.scrolled .nav {
  max-width: 820px; margin-top: .6rem; padding: .3rem 1rem; border-radius: 999px;
  background: rgba(11, 15, 25, .7); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-color: var(--border); box-shadow: 0 8px 32px rgba(0, 0, 0, .45), 0 0 24px rgba(6, 182, 212, .08);
}
.brand { font-weight: 800; letter-spacing: .06em; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.nav-links { display: flex; gap: 1.5rem; list-style: none; margin: 0 auto; padding: 0; }
.nav-links a { position: relative; color: var(--muted); padding: .4rem 0; transition: color var(--t); }
.nav-links a::after {
  content: ""; position: absolute; inset-inline: 0; bottom: 0; height: 2px; border-radius: 2px;
  background: var(--grad); box-shadow: 0 0 10px var(--cyan); transform: scaleX(0); transition: transform var(--t);
}
.nav-links a:hover, .nav-links a.active { color: var(--text); }
.nav-links a.active::after { transform: scaleX(1); }
.lang { display: flex; align-items: center; gap: .25rem; color: var(--border); }
.lang button { background: none; border: 0; color: var(--muted); font-weight: 600; padding: .5rem .6rem; cursor: pointer; min-height: 44px; transition: color var(--t); }
.lang button[aria-pressed="true"] { color: var(--accent-hover); }
.lang button:hover { color: var(--text); }

/* ==========================================================
   4. HERO
   ========================================================== */
.hero { max-width: 1080px; margin: 0 auto; padding: 5rem 1.25rem 4rem; display: flex; align-items: center; gap: 4rem; }
.hero-photo { position: relative; isolation: isolate; flex: none; }
.hero-photo img {
  width: clamp(200px, 28vw, 320px); aspect-ratio: 1; object-fit: cover; border-radius: 50%;
  border: 2px solid rgba(6, 182, 212, .45); background: var(--panel);
  animation: float 7s ease-in-out infinite;
}
/* Ambient glow + pulse ring behind the photo */
.hero-photo::before {
  content: ""; position: absolute; inset: -16%; border-radius: 50%; z-index: -1; filter: blur(22px);
  background: radial-gradient(circle, rgba(6, 182, 212, .4), rgba(37, 99, 235, .22) 45%, rgba(139, 92, 246, .12) 62%, transparent 72%);
  animation: glow 4s ease-in-out infinite;
}
.hero-photo::after {
  content: ""; position: absolute; inset: -3%; border-radius: 50%; z-index: -1;
  border: 2px solid rgba(6, 182, 212, .55); animation: ring 3s ease-out infinite;
}
@keyframes float { 50% { transform: translateY(-8px); } }
@keyframes glow { 50% { transform: scale(1.12); opacity: .7; } }
@keyframes ring { from { transform: scale(.95); opacity: .8; } to { transform: scale(1.3); opacity: 0; } }

h1 {
  font-size: clamp(2.4rem, 6vw, 4rem); line-height: 1.1; margin: 0 0 .5rem; letter-spacing: -.02em;
  background: linear-gradient(120deg, #fff 30%, var(--accent-hover)); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.title { color: var(--accent-hover); font-size: 1.25rem; font-weight: 600; margin: 0 0 1.25rem; min-height: 1.7em; }
.caret { display: inline-block; width: 2px; height: 1.1em; margin-inline-start: 3px; vertical-align: -.15em; background: var(--cyan); box-shadow: 0 0 8px var(--cyan); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.intro { color: var(--muted); max-width: 52ch; margin: 0 0 2rem; font-size: 1.05rem; }
.hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 1.25rem 1.5rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 46px; padding: .7rem 1.5rem;
  background: var(--grad); color: #fff; font-weight: 600; border: 0; border-radius: 999px; cursor: pointer;
  box-shadow: 0 0 24px rgba(37, 99, 235, .4); transition: transform var(--t), box-shadow var(--t), filter var(--t);
}
.btn:hover { transform: translateY(-2px); filter: brightness(1.1); box-shadow: 0 8px 30px rgba(6, 182, 212, .45); }
.btn.ghost { background: transparent; border: 1px solid var(--border); box-shadow: none; }
.btn.ghost:hover { border-color: var(--cyan); box-shadow: 0 0 20px rgba(6, 182, 212, .25); }
.social { display: flex; flex-wrap: wrap; gap: 1.25rem; }
.social a, .contact-links a { color: var(--muted); transition: color var(--t); }
.social a:hover { color: var(--accent-hover); }

/* ==========================================================
   5. SECTIONS, SKILLS, FILTERS
   ========================================================== */
.section { max-width: 1080px; margin: 0 auto; padding: 4rem 1.25rem; }
h2 { font-size: clamp(1.7rem, 4vw, 2.2rem); margin: 0 0 1.5rem; letter-spacing: -.01em; }
h2::after { content: ""; display: block; width: 48px; height: 3px; margin-top: .6rem; background: var(--grad); border-radius: 3px; box-shadow: 0 0 14px rgba(6, 182, 212, .7); }
.lead { color: var(--muted); max-width: 68ch; margin: 0 0 1rem; }

.filters { display: flex; flex-wrap: wrap; gap: .5rem; margin: 1.75rem 0 0; }
.filters button {
  position: relative; padding: .4rem 1.1rem; min-height: 40px; border: 0; border-radius: 999px; cursor: pointer;
  background: var(--panel); color: var(--muted); transition: color var(--t), background var(--t), box-shadow var(--t);
}
.filters button:hover { color: var(--text); }
.filters button[aria-pressed="true"] { background: var(--grad); color: #fff; box-shadow: 0 0 18px rgba(37, 99, 235, .45); }
.filters button[aria-pressed="true"]::after { display: none; }

.skills { display: flex; flex-wrap: wrap; gap: .6rem; list-style: none; padding: 0; margin: 1.25rem 0 0; }
.skills li {
  position: relative; padding: .35rem .95rem; border-radius: 999px; background: var(--panel);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); font-size: .92rem; cursor: default;
  transition: transform var(--t), opacity var(--t), box-shadow var(--t), color var(--t);
}
.skills li:hover, .skills li:focus-visible { transform: scale(1.1); color: #fff; box-shadow: 0 0 20px rgba(6, 182, 212, .5), 0 0 6px rgba(37, 99, 235, .6); }
.skills li.out { opacity: 0; transform: scale(.8); }
.skills li[hidden] { display: none; }

/* Dynamic tooltip (positioned by JS) */
.tooltip {
  position: fixed; left: 0; top: 0; z-index: 60; min-width: 130px; padding: .55rem .8rem; border-radius: 12px;
  background: rgba(11, 15, 25, .92); border: 1px solid rgba(6, 182, 212, .4); box-shadow: 0 8px 28px rgba(0, 0, 0, .5);
  font-size: .82rem; color: var(--muted); pointer-events: none; opacity: 0; transform: translate(-50%, -90%);
  transition: opacity .2s var(--ease);
}
.tooltip.show { opacity: 1; }
.tooltip strong { display: flex; justify-content: space-between; gap: 1rem; color: var(--text); margin-bottom: .35rem; }
.tooltip strong span { color: var(--accent-hover); font-weight: 600; }
.tooltip .bar { height: 4px; border-radius: 4px; background: var(--border); overflow: hidden; }
.tooltip .bar i { display: block; height: 100%; background: var(--grad); }

/* ==========================================================
   6. PROJECT CARDS (3D tilt + spotlight)
   ========================================================== */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 1.75rem; perspective: 1200px; }
.card-wrap { display: flex; }
.card {
  --mx: 50%; --my: 50%; width: 100%;
  display: flex; flex-direction: column; height: 100%; border-radius: var(--radius); overflow: hidden; cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, .3), 0 12px 32px rgba(0, 0, 0, .35), 0 0 0 rgba(6, 182, 212, 0);
  transition: transform .25s var(--ease), box-shadow var(--t); will-change: transform;
}
.card:hover { box-shadow: 0 2px 4px rgba(0, 0, 0, .3), 0 22px 48px rgba(0, 0, 0, .5), 0 0 36px rgba(6, 182, 212, .15); }
.card::before { /* cursor spotlight */
  content: ""; position: absolute; inset: 0; z-index: 2; pointer-events: none; opacity: 0; transition: opacity var(--t);
  background: radial-gradient(320px circle at var(--mx) var(--my), rgba(6, 182, 212, .18), transparent 60%);
}
.card:hover::before { opacity: 1; }
.card-img { aspect-ratio: 16 / 10; overflow: hidden; background: #111827; }
.card-img img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s var(--ease); }
.card:hover .card-img img { transform: scale(1.06); }
.card-body { display: flex; flex-direction: column; flex: 1; padding: 1.4rem; }
.card h3 { margin: 0 0 .5rem; font-size: 1.2rem; }
.card p { margin: 0 0 1.4rem; color: var(--muted); flex: 1; }
.card .btn { align-self: flex-start; box-shadow: none; }

/* ==========================================================
   7. MODAL
   ========================================================== */
.modal { width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; padding: 1rem; border: 0; background: transparent; color: var(--text); }
.modal[open] { display: grid; place-items: center; }
.modal::backdrop { background: rgba(5, 8, 15, .7); backdrop-filter: blur(6px); }
.modal-box {
  width: min(880px, 100%); max-height: 90vh; overflow: auto; border-radius: 22px; background: rgba(15, 21, 36, .92);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .6), 0 0 60px rgba(37, 99, 235, .15);
  opacity: 0; transform: translateY(28px) scale(.97); transition: opacity var(--t), transform var(--t);
}
.modal.show .modal-box { opacity: 1; transform: none; }
.modal-close {
  position: absolute; top: .75rem; inset-inline-end: .75rem; z-index: 3; width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--border); background: rgba(11, 15, 25, .75); font-size: 1.5rem; line-height: 1; cursor: pointer; transition: var(--t);
}
.modal-close:hover { border-color: var(--cyan); color: var(--accent-hover); transform: rotate(90deg); }
.modal-media { aspect-ratio: 16 / 7; overflow: hidden; background: #111827; }
.modal-media img { width: 100%; height: 100%; object-fit: cover; }
.modal-body { padding: 1.5rem 1.75rem 1.75rem; }
.modal-body h3 { margin: 0 0 .6rem; font-size: 1.6rem; }
.modal-body h4 { margin: 1.4rem 0 .6rem; font-size: .95rem; color: var(--muted); font-weight: 600; }
.modal-body p { color: var(--muted); margin: 0; max-width: 70ch; }
.badges { display: flex; flex-wrap: wrap; gap: .5rem; list-style: none; padding: 0; margin: 0; }
.badges li { padding: .25rem .8rem; font-size: .85rem; border-radius: 999px; border: 1px solid rgba(6, 182, 212, .35); background: rgba(6, 182, 212, .08); color: var(--accent-hover); }
.modal-actions { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 1.5rem; }
.preview { margin-top: 1.25rem; }
.preview .note { margin-top: .6rem; font-size: .85rem; }
.frame { border-radius: 14px; overflow: hidden; border: 1px solid var(--border); aspect-ratio: 16 / 10; background: #fff; }
.frame iframe { width: 100%; height: 100%; border: 0; }

/* ==========================================================
   8. CONTACT, FOOTER, BACK-TO-TOP
   ========================================================== */
.contact-links { display: flex; flex-wrap: wrap; gap: 1rem; }
.contact-links a {
  position: relative; min-height: 46px; display: inline-flex; align-items: center; padding: .6rem 1.4rem;
  border-radius: 999px; background: var(--panel); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); color: var(--text);
  transition: color var(--t), transform var(--t), box-shadow var(--t);
}
.contact-links a::after { content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1px; pointer-events: none; background: linear-gradient(135deg, rgba(37, 99, 235, .6), rgba(6, 182, 212, .4)); -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude; }
.contact-links a:hover { color: var(--accent-hover); transform: translateY(-2px); box-shadow: 0 0 24px rgba(6, 182, 212, .25); }
.footer { max-width: 1080px; margin: 2rem auto 0; padding: 1.75rem 1.25rem; border-top: 1px solid var(--border); display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; color: var(--muted); }
.footer p { margin: 0; }

.to-top {
  position: fixed; bottom: 1.25rem; inset-inline-end: 1.25rem; z-index: 30; width: 48px; height: 48px; border-radius: 50%;
  display: grid; place-items: center; border: 1px solid rgba(6, 182, 212, .4); cursor: pointer; color: #fff;
  background: rgba(11, 15, 25, .75); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 0 22px rgba(6, 182, 212, .25);
  opacity: 0; transform: translateY(16px); pointer-events: none; transition: opacity var(--t), transform var(--t), box-shadow var(--t);
}
.to-top.show { opacity: 1; transform: none; pointer-events: auto; }
.to-top:hover { box-shadow: 0 0 32px rgba(6, 182, 212, .6); }

/* ==========================================================
   9. SCROLL REVEAL
   ========================================================== */
.reveal { opacity: 0; transform: translateY(24px); transition: opacity .7s var(--ease) var(--d, 0ms), transform .7s var(--ease) var(--d, 0ms); }
.reveal.visible { opacity: 1; transform: none; }

/* ==========================================================
   10. RTL + RESPONSIVE + REDUCED MOTION
   ========================================================== */
[dir="rtl"] .hero { flex-direction: row-reverse; }
[dir="rtl"] h1, [dir="rtl"] .title { letter-spacing: 0; }

@media (max-width: 860px) {
  .hero, [dir="rtl"] .hero { flex-direction: column; text-align: center; gap: 2.5rem; padding-top: 3rem; }
  .intro { margin-inline: auto; }
  .hero-actions, .social { justify-content: center; }
  .modal-media { aspect-ratio: 16 / 9; }
}
@media (max-width: 600px) {
  .nav { gap: .5rem; padding-inline: .75rem; }
  .nav-links { gap: .75rem; font-size: .9rem; }
  .brand { display: none; }
  .section { padding: 3rem 1.25rem; }
  .footer { flex-direction: column; align-items: center; text-align: center; }
  .modal { padding: .5rem; }
  .modal-body { padding: 1.25rem; }
}
@media (hover: none) { .card::before { display: none; } }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .reveal { opacity: 1; transform: none; }
}

