/* Hosted here so slow third-party font services cannot block the page. */
@font-face {
  font-family: "Vazirmatn";
  src: url("../assets/fonts/Vazirmatn-variable.woff2") format("woff2");
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
}

:root {
    --bg: #0a0b0e;
    --bg-2: #0f1116;
    --ink: #eef1f6;
    --muted: #8b93a3;
    --line: #1c2029;
    --card: #101319;
    --card-hover: #141922;
    --accent: #ff3b3b;
    --accent-soft: #ff6a6a;
    --accent-dim: rgba(255,59,59,.14);
    --cyan: #2ee6ff;
    --term-bg: #0b0d12;
    --term-chrome: #12151c;
    --term-text: #d6deeb;
    --term-dim: #6f7a8d;
    --term-green: #3fb950;
    --term-blue: #58a6ff;
    --term-yellow: #e3b341;
    --term-pink: #ff6a9a;
    --mono: "SF Mono", "JetBrains Mono", "Fira Code", ui-monospace, Menlo, monospace;
    --fa: "Vazirmatn", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  }

  * { box-sizing: border-box; margin: 0; padding: 0; }
  html { scroll-behavior: smooth; }
  body {
    font-family: var(--sans); background: var(--bg); color: var(--ink);
    line-height: 1.5; -webkit-font-smoothing: antialiased; overflow-x: hidden;
  }
  a { color: inherit; text-decoration: none; }
  .wrap { max-width: 1080px; margin: 0 auto; padding: 0 24px; position: relative; z-index: 2; }


  #particles { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
  .glow { position: fixed; top: -20%; left: 50%; transform: translateX(-50%); width: 900px; height: 700px; z-index: 0; pointer-events: none;
    background: radial-gradient(circle, rgba(255,59,59,.10) 0%, rgba(255,59,59,0) 62%); filter: blur(20px); }

  /* Content is readable before JavaScript; reveal is an optional entrance effect. */
  .reveal { opacity: 1; transform: none; }
  .reveal.in { animation: revealIn .7s cubic-bezier(.22,.61,.36,1) both; }
  @keyframes revealIn { from { opacity: 0; transform: translateY(22px); } to { opacity: 1; transform: none; } }

  /* ---------- nav ---------- */
  /* no hard rule under the bar any more — a soft shadow separates it from the page once you scroll */
  nav { position: sticky; top: 0; z-index: 20; background: rgba(10,11,14,.72); backdrop-filter: saturate(160%) blur(14px); box-shadow: 0 10px 30px -18px rgba(0,0,0,.8); }
  nav .wrap { display: flex; align-items: center; justify-content: space-between; height: 62px; }
  .logo { font-family: var(--mono); font-weight: 600; font-size: 16px; letter-spacing: -.3px; display: flex; align-items: center; gap: 10px; }
  .logo > span { color: var(--accent); }
  .logo > span + span { color: var(--muted); }
  .logo .l { display: inline-block; transition: transform .25s cubic-bezier(.34,1.56,.64,1), color .2s; }
  .logo:hover .l { transform: translateY(-3px); color: var(--accent-soft); }
  .nav-links { display: flex; gap: 6px; font-size: 14px; color: var(--muted); }
  /* nav items: soft pill highlight instead of the thin underline that used to grow under them */
  .nav-links a { position: relative; padding: 6px 12px; border-radius: 8px; transition: color .16s, background .16s; }
  .nav-links a:hover { color: var(--ink); background: rgba(255,255,255,.05); }
  .nav-links a.on { color: var(--ink); background: rgba(255,59,59,.12); box-shadow: inset 0 0 0 1px rgba(255,59,59,.25); }

  /* ---------- hero ---------- */
  .hero { padding: 72px 0 30px; text-align: center; }
  .hero .wrap { display: flex; flex-direction: column; align-items: center; }


  .kicker { font-family: var(--mono); font-size: 13px; color: var(--accent); margin-bottom: 18px; min-height: 20px; }
  .hero h1 { font-size: 54px; line-height: 1.1; letter-spacing: -1.8px; font-weight: 700; margin-bottom: 22px; max-width: 26ch; padding: 0 8px; }
  .hero h1 .w { display: inline-block; opacity: 0; transform: translateY(18px); animation: rise .6s cubic-bezier(.22,.61,.36,1) forwards; }
  @keyframes rise { to { opacity: 1; transform: none; } }
  /* shimmer sweep over headline after rise */
  .hero h1.shine {
    background: linear-gradient(100deg, var(--ink) 40%, #fff 50%, var(--ink) 60%);
    background-size: 220% 100%; -webkit-background-clip: text; background-clip: text; color: transparent;
    animation: shine 2.6s ease-in-out 1.4s 1;
  }
  @keyframes shine { from { background-position: 120% 0; } to { background-position: -120% 0; } }

  .role { font-family: var(--mono); font-size: 16px; color: var(--muted); margin-bottom: 24px; height: 24px; }
  .role .typed { color: var(--ink); }
  .role .caret { display: inline-block; width: 9px; height: 18px; margin-left: 3px; background: var(--accent); vertical-align: -3px; animation: blink 1s steps(1) infinite; }
  @keyframes blink { 50% { opacity: 0; } }

  .hero p { font-size: 17px; color: var(--muted); max-width: 52ch; margin-bottom: 30px; }
  .hero p .ln { display: block; opacity: 0; animation: rise .6s cubic-bezier(.22,.61,.36,1) forwards; }
  .hero-cta { display: flex; gap: 14px; justify-content: center; margin-bottom: 52px; }
  .btn { font-size: 14px; font-weight: 500; padding: 11px 20px; border-radius: 9px; border: 1px solid transparent; transition: .18s; font-family: var(--sans); position: relative; overflow: hidden; cursor: pointer; }
  .btn-primary { background: var(--accent); color: #fff; box-shadow: 0 8px 24px -8px rgba(255,59,59,.5); }
  .btn-primary::after { content: ''; position: absolute; top: 0; left: -80%; width: 50%; height: 100%; background: linear-gradient(100deg, transparent, rgba(255,255,255,.35), transparent); transform: skewX(-20deg); transition: left .45s ease; }
  .btn-primary:hover::after { left: 130%; }
  .btn-primary:hover { background: var(--accent-soft); transform: translateY(-1px); box-shadow: 0 12px 30px -8px rgba(255,59,59,.6); }
  .btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
  .btn-ghost:hover { border-color: var(--accent); color: var(--accent-soft); }

  /* ---------- terminal ---------- */
  .terminal { width: 100%; max-width: 860px; background: var(--term-bg); border-radius: 14px; border: 1px solid var(--line);
    box-shadow: 0 30px 70px -20px rgba(0,0,0,.7), 0 0 0 1px rgba(255,59,59,.06); overflow: hidden; text-align: left; font-family: var(--mono); position: relative; }
  .terminal::before { content: ''; position: absolute; inset: 0; border-radius: 14px; padding: 1px;
    background: linear-gradient(135deg, rgba(255,59,59,.35), rgba(255,59,59,0) 40%);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0); -webkit-mask-composite: xor; mask-composite: exclude; pointer-events: none; transition: opacity .4s, filter .4s; }
  /* hero terminal comes alive under the cursor: lifts, glows, a light sweep runs across and the prompt nudges */
  .hero .terminal { transition: transform .4s cubic-bezier(.22,.61,.36,1), box-shadow .4s, border-color .4s; }
  .hero .terminal:hover, .hero .terminal:focus-within { transform: translateY(-5px) scale(1.005); border-color: rgba(255,59,59,.38);
    box-shadow: 0 44px 90px -26px rgba(0,0,0,.9), 0 0 0 1px rgba(255,59,59,.18), 0 0 70px -18px rgba(255,59,59,.5); }
  .hero .terminal:hover::before, .hero .terminal:focus-within::before { filter: brightness(1.8) saturate(1.2); }
  .hero .terminal::after { content: ''; position: absolute; top: 0; left: -45%; width: 40%; height: 100%; pointer-events: none; opacity: 0;
    background: linear-gradient(100deg, transparent, rgba(255,255,255,.045), transparent); transform: skewX(-16deg); }
  .hero .terminal:hover::after { animation: sweep 1.1s cubic-bezier(.22,.61,.36,1) both; }
  @keyframes sweep { 0% { left: -45%; opacity: 1; } 100% { left: 120%; opacity: 0; } }
  .hero .terminal .term-title { transition: color .3s; }
  .hero .terminal:hover .term-title { color: var(--accent-soft); }
  .hero .terminal .prompt-sym { display: inline-block; }
  .hero .terminal:hover .prompt-sym { animation: nudge .7s ease-in-out infinite alternate; }
  @keyframes nudge { to { transform: translateX(4px); } }
  .hero .terminal #cmdInput::placeholder { transition: color .3s; }
  .hero .terminal:hover #cmdInput::placeholder, .hero .terminal:focus-within #cmdInput::placeholder { color: var(--accent-soft); }
  .term-chrome { background: var(--term-chrome); padding: 12px 16px; display: flex; align-items: center; gap: 8px; border-bottom: 1px solid rgba(255,255,255,.05); }
  .dot { width: 12px; height: 12px; border-radius: 50%; }
  .dot.r { background: #ff5f57; } .dot.y { background: #febc2e; } .dot.g { background: #28c840; }
  .term-title { font-size: 12px; color: var(--term-dim); }
  .term-body { padding: 18px 18px 16px; height: 340px; overflow-y: auto; font-size: 13.5px; line-height: 1.65; color: var(--term-text); }
  .term-body::-webkit-scrollbar { width: 8px; }
  .term-body::-webkit-scrollbar-thumb { background: #2a2f3a; border-radius: 4px; }
  .line { white-space: pre-wrap; word-break: break-word; animation: lineIn .38s cubic-bezier(.22,.61,.36,1) both; }
  @keyframes lineIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
  .line.fa { direction: rtl; text-align: right; font-family: var(--fa); font-size: 14.5px; unicode-bidi: plaintext; }
  .line .wd { display: inline; opacity: 0; animation: wordIn .45s ease both; }
  .line .emo { display: inline-block; margin-inline-end: 8px; font-size: 16px; animation: emoIn .5s cubic-bezier(.34,1.56,.64,1) both; }
  @keyframes emoIn { from { opacity: 0; transform: scale(.4) rotate(-20deg); } to { opacity: 1; transform: none; } }
  @keyframes wordIn { to { opacity: 1; } }
  .line.assistant { padding: 6px 10px; margin: 4px 0; border-left: 2px solid var(--accent); background: rgba(255,59,59,.05); border-radius: 0 6px 6px 0; }
  .line.assistant.fa { border-left: none; border-right: 2px solid var(--accent); border-radius: 6px 0 0 6px; }
  .cmd-echo.fa { direction: rtl; font-family: var(--fa); unicode-bidi: plaintext; }
  .prompt-sym { color: var(--accent); } .prompt-path { color: var(--term-blue); } .cmd-echo { color: var(--term-text); }
  .out-dim { color: var(--term-dim); } .out-blue { color: var(--term-blue); } .out-yellow { color: var(--term-yellow); }
  .out-pink { color: var(--term-pink); } .out-green { color: var(--term-green); } .out-red { color: var(--accent-soft); } .out-cyan { color: var(--cyan); }
  .input-row { display: flex; align-items: center; gap: 8px; padding: 0 18px 16px; }
  #cmdInput { flex: 1; min-width: 0; background: transparent; unicode-bidi: plaintext; border: none; outline: none; color: var(--term-text); font-family: var(--mono); font-size: 13.5px; caret-color: var(--accent); }

  /* ---------- sections ---------- */
  section { padding: 66px 0; position: relative; z-index: 2; }
  .sec-head { margin-bottom: 36px; }
  .sec-head .kicker { margin-bottom: 10px; }
  .sec-head h2 { font-size: 30px; letter-spacing: -.8px; font-weight: 700; font-variant-numeric: tabular-nums; }
  .sec-head h2 .sc { color: var(--accent); }

  /* projects with imagery */
  .projects { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
  .proj { background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; position: relative;
    transition: transform .2s cubic-bezier(.22,.61,.36,1), border-color .2s, box-shadow .2s, background .2s; display: flex; flex-direction: column; }
  .proj::after { content: ''; position: absolute; top: 0; left: 0; width: 0; height: 2px; background: linear-gradient(90deg, var(--accent), transparent); transition: width .3s ease; z-index: 3; }
  .proj:hover { border-color: rgba(255,59,59,.35); transform: translateY(-4px); background: var(--card-hover); box-shadow: 0 18px 40px -20px rgba(255,59,59,.25); }
  .proj:hover::after { width: 100%; }
  .proj-media { height: 190px; position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden;
    background: radial-gradient(ellipse at center, rgba(255,255,255,.04), transparent 70%); border-bottom: 1px solid var(--line); }
  .proj-media img { max-height: 70%; max-width: 70%; object-fit: contain; transition: transform .5s cubic-bezier(.22,.61,.36,1); filter: drop-shadow(0 12px 24px rgba(0,0,0,.6)); }
  .proj:hover .proj-media img { transform: scale(1.08) translateY(-4px); }
  .proj-media.cover img, .proj-media.cover video { max-width: 100%; max-height: 100%; width: 100%; height: 100%; object-fit: cover; filter: none; }
  .proj:hover .proj-media.cover video { transform: scale(1.04); transition: transform .5s cubic-bezier(.22,.61,.36,1); }
  .proj-media.bg { background-size: cover; background-position: center; }
  .proj-media.bg::before { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(10,11,14,.15), rgba(10,11,14,.85)); }
  .proj-media.bg img { position: relative; }
  .proj-media.cp { background: radial-gradient(circle at 50% 60%, rgba(46,230,255,.16), transparent 62%); }
  .proj-media.wbio { background: radial-gradient(circle at 50% 60%, rgba(155,123,255,.2), transparent 62%); }
  .proj-media.wbio img { max-height: 58%; }
  .proj-media.fps { background: radial-gradient(circle at 50% 60%, rgba(255,106,61,.18), transparent 62%); }
  .proj-media.fps img { max-height: 56%; filter: saturate(.55) opacity(.85); }
  .proj-tag.discontinued { background: rgba(255,106,61,.12); color: #ff9a7a; }
  .stack-box .v .disc { font-family: var(--mono); font-size: 11px; padding: 2px 7px; border-radius: 6px; background: rgba(255,106,61,.12); color: #ff9a7a; margin-inline-start: 6px; vertical-align: 1px; }
  .stack-box .k a { color: inherit; text-decoration: none; border-bottom: 1px dotted var(--term-dim); } .stack-box .k a:hover { color: var(--accent-soft); }
  .proj-body { padding: 22px 24px 24px; }
  .proj-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
  .proj-tag { font-family: var(--mono); font-size: 11px; padding: 4px 9px; border-radius: 6px; background: #161b26; color: var(--term-blue); }
  .proj-tag.live { background: var(--accent-dim); color: var(--accent-soft); }
  .proj-tag.cyan { background: rgba(46,230,255,.12); color: var(--cyan); }
  .proj-tag.violet { background: rgba(155,123,255,.14); color: #b9a4ff; }
  .proj h3 { font-size: 19px; margin-bottom: 8px; letter-spacing: -.3px; }
  .proj h3 .l { display: inline-block; transition: transform .25s cubic-bezier(.34,1.56,.64,1), color .2s; }
  .proj:hover h3 .l { color: var(--accent-soft); }
  .proj p { font-size: 14px; color: var(--muted); }
  .proj-more { font-family: var(--mono); font-size: 12px; color: var(--term-dim); transition: color .2s; }
  .proj:hover .proj-more { color: var(--accent-soft); }
  .proj-meta { margin-top: 16px; font-family: var(--mono); font-size: 12px; color: var(--term-dim); display: flex; gap: 16px; }

  /* luna banner */
  .luna { position: relative; border-radius: 16px; overflow: hidden; border: 1px solid var(--line); min-height: 300px;
    display: grid; grid-template-columns: 1.1fr 1fr; align-items: center; gap: 24px; padding: 40px; background: #0c0f14; }
  .luna::before { content: ''; position: absolute; inset: 0; background: url('../assets/luna-bg.jpg?v=20260916c') center/cover; opacity: .25; filter: saturate(.8) blur(2px); }
  .luna::after { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(10,11,14,.95) 30%, rgba(10,11,14,.55)); }
  .luna > * { position: relative; z-index: 2; }
  .luna h3 { font-size: 34px; letter-spacing: -1px; margin-bottom: 12px; }
  .luna p { color: var(--muted); max-width: 46ch; margin-bottom: 22px; }
  .ip { display: inline-flex; align-items: center; gap: 12px; font-family: var(--mono); font-size: 15px; padding: 12px 16px; border-radius: 10px;
    background: rgba(255,255,255,.04); border: 1px solid var(--line); transition: border-color .2s, background .2s; }
  .ip:hover { border-color: var(--cyan); background: rgba(46,230,255,.06); }
  .ip b { color: var(--cyan); font-weight: 500; }
  .ip small { color: var(--term-dim); font-size: 12px; }
  .luna-art { text-align: center; }
  .luna-art img { width: 78%; max-width: 320px; filter: drop-shadow(0 20px 40px rgba(46,230,255,.25)); animation: floaty 5s ease-in-out infinite; }
  @keyframes floaty { 50% { transform: translateY(-10px); } }

  #about { background: var(--bg-2); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
  /* ---------- profile: avatar + channel links over a wall of thumbnails ----------
     .profile      = boxed card (index About section)
     .profile-hero = full-bleed band with no frame (top of about-me) */
  .profile, .profile-hero { position: relative; overflow: hidden; isolation: isolate; }
  .profile { border-radius: 16px; border: 1px solid var(--line); background: var(--card); margin-bottom: 40px; min-height: 260px; display: flex; align-items: center; justify-content: center; padding: 44px 28px; }
  .profile-hero { padding: 64px 0 44px; border-bottom: 1px solid var(--line); background: var(--bg); }
  /* the wall stays invisible until every thumbnail has loaded (fx.js adds .ready), then fades in */
  /* direction: ltr — in the Persian (rtl) layout the over-wide rows would anchor to the right edge and the drift would
     slide them off to the left, emptying the wall; the wall is decoration, so it always flows ltr */
  .thumb-wall { position: absolute; inset: -24px; direction: ltr; display: flex; flex-direction: column; justify-content: center; gap: 10px; opacity: 0; transition: opacity 1.4s ease; filter: saturate(.8); pointer-events: none; z-index: 0; transform: rotate(-3deg) scale(1.08); }
  .thumb-wall.ready { opacity: var(--wall-opacity, .16); }
  .profile-hero .thumb-wall { inset: -40px -10%; gap: 14px; transform: rotate(-4deg) scale(1.06); }
  .profile-hero .thumb-wall.ready { opacity: var(--wall-opacity, .55); }
  .thumb-row { display: flex; gap: 10px; width: max-content; animation: drift 90s linear infinite; }
  .profile-hero .thumb-row { gap: 14px; }
  .thumb-row:nth-child(2) { animation-direction: reverse; animation-duration: 110s; }
  .thumb-row:nth-child(3) { animation-duration: 130s; }
  .thumb-row img, .thumb-row .ph { flex: none; width: 210px; aspect-ratio: 16 / 9; border-radius: 8px; object-fit: cover; display: block; background: var(--bg-2); }
  .profile-hero .thumb-row img, .profile-hero .thumb-row .ph { width: 260px; border-radius: 10px; }
  .thumb-row .ph { background: linear-gradient(135deg, rgba(255,59,59,calc(.25 + var(--i) * .08)), rgba(139,92,246,.2) 60%, rgba(46,230,255,.15)); border: 1px solid rgba(255,255,255,.06); }
  .thumb-wall.placeholder.ready { opacity: .5; }   /* only when no thumbnails exist at all */
  @keyframes drift { to { transform: translateX(-50%); } }
  .profile::after { content: ''; position: absolute; inset: 0; z-index: 1; pointer-events: none;
    background: radial-gradient(ellipse at center, rgba(16,19,25,.82) 0%, rgba(16,19,25,.55) 38%, rgba(16,19,25,.15) 75%, rgba(16,19,25,0) 100%); }   /* a little lighter so the middle of the wall is still visible behind the card */
  .profile-hero::after { content: ''; position: absolute; inset: 0; z-index: 1; pointer-events: none;
    background: linear-gradient(180deg, rgba(10,11,14,.45), rgba(10,11,14,.1) 40%, rgba(10,11,14,.9) 100%), radial-gradient(ellipse at 22% 50%, rgba(10,11,14,.9) 0%, rgba(10,11,14,.5) 30%, rgba(10,11,14,0) 65%); }
  .profile-hero .wrap { z-index: 2; }
  .profile-card { position: relative; z-index: 2; display: flex; align-items: center; gap: 26px; }
  .avatar-link { display: block; border-radius: 50%; flex: none; }
  .profile .avatar, .profile-hero .avatar { width: 116px; height: 116px; border-radius: 50%; object-fit: cover; display: block; border: 3px solid var(--bg);
    box-shadow: 0 0 0 2px var(--accent), 0 24px 60px -20px rgba(255,59,59,.7); transition: transform .3s cubic-bezier(.22,.61,.36,1), box-shadow .3s; }
  .profile-hero .avatar { width: 132px; height: 132px; }
  .avatar-link:hover .avatar { transform: scale(1.04); box-shadow: 0 0 0 2px var(--accent-soft), 0 24px 60px -16px rgba(255,59,59,.9); }
  .profile h3, .profile-hero h3 { font-size: 32px; letter-spacing: -.9px; line-height: 1.1; }
  .profile-hero h3 { font-size: 40px; letter-spacing: -1.2px; }
  .profile .handle, .profile-hero .handle { font-family: var(--mono); font-size: 13px; color: var(--muted); margin: 6px 0 14px; }
  .profile-links { display: flex; flex-wrap: wrap; gap: 8px; }
  .profile-links a { font-family: var(--mono); font-size: 12px; padding: 7px 12px; border-radius: 8px; border: 1px solid var(--line); color: var(--ink); background: rgba(10,11,14,.55); transition: border-color .2s, background .2s, transform .2s; }
  .profile-links a:hover { border-color: rgba(255,59,59,.45); background: rgba(255,59,59,.1); transform: translateY(-1px); }
  .profile-links a small { color: var(--term-dim); font-size: 11px; margin-left: 6px; }
  .profile-links a.soon { opacity: .45; pointer-events: none; }
  .profile-line { position: relative; z-index: 2; margin-top: 26px; font-size: 17px; color: var(--muted); max-width: 60ch; }
  .profile-line b { color: var(--ink); font-weight: 600; }
  .profile-hero + .page-head { padding-top: 44px; }
  /* about-me hero: everything centered, with an entrance sequence and a live avatar ring */
  .profile-hero { padding: 72px 0 52px; }
  .profile-hero .profile-card { flex-direction: column; text-align: center; gap: 20px; }
  .profile-hero .profile-links { justify-content: center; }
  .profile-hero .profile-line { text-align: center; margin: 28px auto 0; }
  /* lighter veil than before: the old one (.9 centre, .5/.9 top/bottom) on top of a .3 wall hid the thumbnails almost completely */
  .profile-hero::after { background: linear-gradient(180deg, rgba(10,11,14,.35), rgba(10,11,14,.05) 45%, rgba(10,11,14,.85) 100%), radial-gradient(ellipse at 50% 50%, rgba(10,11,14,.7) 0%, rgba(10,11,14,.25) 35%, rgba(10,11,14,0) 70%); }
  .profile-hero .thumb-wall { transform: rotate(-4deg) scale(1.06) translate(var(--px, 0px), var(--py, 0px)); transition: transform .6s cubic-bezier(.22,.61,.36,1), opacity 1.4s ease; }
  .profile-hero .avatar-link { position: relative; animation: floaty 5s ease-in-out infinite; }
  .profile-hero .avatar-link::before { content: ''; position: absolute; inset: -7px; border-radius: 50%; padding: 2px; background: conic-gradient(from 0deg, var(--accent), rgba(255,59,59,0) 30%, rgba(46,230,255,.6) 55%, rgba(255,59,59,0) 80%, var(--accent)); animation: spin 4s linear infinite;
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0); -webkit-mask-composite: xor; mask-composite: exclude; }
  .profile-hero .avatar-link::after { content: ''; position: absolute; inset: -7px; border-radius: 50%; box-shadow: 0 0 0 0 rgba(255,59,59,.45); animation: pulse 2.6s ease-out infinite; }
  .profile-hero .avatar { width: 148px; height: 148px; box-shadow: 0 0 0 2px var(--bg), 0 30px 70px -24px rgba(255,59,59,.8); }
  @keyframes spin { to { transform: rotate(360deg); } }
  @keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(255,59,59,.45); } 100% { box-shadow: 0 0 0 22px rgba(255,59,59,0); } }
  .profile-hero h3 { font-size: 44px; letter-spacing: -1.4px; background: linear-gradient(100deg, var(--ink) 30%, #fff 50%, var(--ink) 70%); background-size: 220% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: shine 3.2s ease-in-out 1.2s infinite; }
  .profile-hero .avatar-link, .profile-hero h3, .profile-hero .handle, .profile-hero .profile-links a, .profile-hero .profile-line { opacity: 0; animation-fill-mode: both; }
  .profile-hero .avatar-link { animation: floaty 5s ease-in-out 1.2s infinite, rise .7s cubic-bezier(.22,.61,.36,1) .1s forwards; }
  .profile-hero h3 { animation: rise .7s cubic-bezier(.22,.61,.36,1) .3s forwards, shine 3.2s ease-in-out 1.4s infinite; }
  .profile-hero .handle { animation: rise .7s cubic-bezier(.22,.61,.36,1) .45s forwards; }
  .profile-hero .profile-links a { animation: rise .6s cubic-bezier(.22,.61,.36,1) forwards; }
  .profile-hero .profile-links a:nth-child(1) { animation-delay: .55s; } .profile-hero .profile-links a:nth-child(2) { animation-delay: .63s; } .profile-hero .profile-links a:nth-child(3) { animation-delay: .71s; } .profile-hero .profile-links a:nth-child(4) { animation-delay: .79s; } .profile-hero .profile-links a:nth-child(5) { animation-delay: .87s; }
  .profile-hero .profile-line { animation: rise .7s cubic-bezier(.22,.61,.36,1) 1s forwards; }
  @media (prefers-reduced-motion: reduce) { .profile-hero .avatar-link, .profile-hero h3, .profile-hero .handle, .profile-hero .profile-links a, .profile-hero .profile-line { opacity: 1; animation: none; } .profile-hero .avatar-link::before, .profile-hero .avatar-link::after { animation: none; } .profile-hero h3 { color: var(--ink); background: none; } }
  @media (max-width: 640px) { .profile-hero .avatar { width: 116px; height: 116px; } .profile-hero h3 { font-size: 32px; } }
  html.fa .profile .handle, html.fa .profile-hero .handle, html.fa .profile-links a { font-family: var(--fa); }
  html.fa .profile-links a small { margin-left: 0; margin-right: 6px; }
  @media (max-width: 640px) { .profile { padding: 36px 20px; } .profile-card { flex-direction: column; text-align: center; gap: 16px; } .profile-links { justify-content: center; } .profile h3 { font-size: 26px; }
    .profile-hero { padding: 40px 0 32px; } .profile-hero h3 { font-size: 30px; } .profile-hero .avatar { width: 108px; height: 108px; } .profile-line { text-align: center; } }
  @media (prefers-reduced-motion: reduce) { .thumb-row { animation: none; } }

  .donate-card p { color: var(--muted); font-size: 14px; line-height: 1.6; margin: 4px 0 14px; }
  .donate-card .btn { text-decoration: none; display: inline-block; margin-bottom: 12px; }
  /* contact page: the "best way" callout */
  .contact-best { border: 1px solid rgba(255,59,59,.3); background: rgba(255,59,59,.06); border-radius: 14px; padding: 22px 24px; margin-bottom: 22px; display: flex; flex-direction: column; gap: 12px; }
  .contact-best .cat { font-family: var(--mono); font-size: 12px; color: var(--accent); }
  .contact-best p { color: var(--ink); font-size: 16px; max-width: 60ch; }

  .about-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 40px; align-items: start; }
  .about p { color: var(--muted); font-size: 16px; margin-bottom: 16px; max-width: 56ch; }
  .about p { font-size: 18px; color: var(--ink); line-height: 1.6; }
  .about-nav { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }
  .about-nav .btn { text-decoration: none; display: inline-block; padding: 11px 18px; }
  .about-nav .btn-ghost:hover { border-color: var(--accent); color: var(--accent-soft); transform: translateY(-1px); }
  @media (max-width: 520px) { .about-nav { flex-direction: column; } .about-nav .btn { text-align: center; } }
  .stack-box { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 24px; font-family: var(--mono); font-size: 13px; }
  .stack-box .row { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--line); }
  .stack-box .row:last-child { border: none; }
  .stack-box .k { color: var(--term-dim); } .stack-box .v { color: var(--ink); }
  .stack-box .v b { color: var(--accent-soft); font-weight: 500; }
  .stack-box .v i { font-style: normal; color: var(--cyan); }
  .stack-box .v { text-align: right; }
  html.fa .stack-box .v { text-align: left; }

  footer { border-top: 1px solid var(--line); padding: 40px 0; color: var(--muted); font-size: 14px; position: relative; z-index: 2; }
  footer .wrap { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 14px 24px; }
  .foot-right { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
  .foot-social { display: flex; gap: 8px; }
  .foot-social a { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; color: var(--muted); background: rgba(255,255,255,.02); transition: border-color .2s, color .2s, transform .2s, background .2s; }
  .foot-social a svg { width: 17px; height: 17px; fill: currentColor; }
  .foot-social a img { width: 17px; height: 17px; object-fit: contain; }
  /* brand colours: tinted at rest, filled on hover (Instagram gets its gradient) */
  .foot-social a { color: var(--brand, var(--muted)); border-color: color-mix(in srgb, var(--brand, #fff) 35%, transparent); background: color-mix(in srgb, var(--brand, #fff) 8%, transparent); }
  .foot-social a:hover { color: #fff; border-color: var(--brand); background: var(--brand); transform: translateY(-2px); box-shadow: 0 8px 20px -8px var(--brand); }
  .foot-social a.s-instagram:hover { background: linear-gradient(45deg, #f9ce34, #ee2a7b, #6228d7); border-color: #ee2a7b; }
  .foot-links { display: flex; gap: 18px; font-family: var(--mono); font-size: 13px; padding-left: 18px; border-left: 1px solid var(--line); }
  html.fa .foot-links { padding-left: 0; padding-right: 18px; border-left: 0; border-right: 1px solid var(--line); }
  @media (max-width: 640px) { footer .wrap { flex-direction: column; align-items: flex-start; } .foot-links { padding-left: 0; border-left: 0; } html.fa .foot-links { padding-right: 0; border-right: 0; } }
  .foot-links a { transition: color .16s; }
  .foot-links a:hover { color: var(--accent-soft); }

  @media (prefers-reduced-motion: reduce) {
    .reveal, .reveal.in { opacity: 1; transform: none; animation: none; }
    .hero h1 .w, .hero p .ln { opacity: 1; transform: none; animation: none; }
    .hero h1.shine { animation: none; color: var(--ink); }
    .luna-art img { animation: none; }
  }
  @media (max-width: 860px) {
    .about-grid, .luna { grid-template-columns: 1fr; }
    .projects { grid-template-columns: 1fr; }
    .hero h1 { font-size: 38px; letter-spacing: -1px; }
    nav .wrap { height: auto; padding: 10px 24px; flex-wrap: wrap; row-gap: 6px; }
    .nav-links { gap: 2px; font-size: 13px; flex-wrap: wrap; }
    .hero-cta { flex-direction: column; width: 100%; }
    .hero-cta .btn, .hero-cta a { width: 100%; }
    .luna { padding: 28px; }
    .luna-art { order: -1; }
    .term-page .term-body { font-size: 13px; }
    .term-page .terminal, .term-caption { width: 94vw; }
    .term-page .terminal { height: 78vh; }
    .setup-grid, .photo-grid { grid-template-columns: 1fr; }
    .page-head h1 { font-size: 34px; }
  }

  /* ---------- full-screen terminal page ---------- */
  .term-page { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 3vh 0; }
  .term-bg { position: absolute; inset: 0; z-index: 0; pointer-events: none; border-radius: inherit;
    background: url('../assets/terminal-bg.jpg?v=2') center/cover no-repeat; opacity: var(--bg-opacity, .12); filter: saturate(1.05); }
  .term-page .terminal > :not(.term-bg) { position: relative; z-index: 1; }
  .term-page .terminal { width: 80vw; height: 80vh; max-width: none; margin: 0; display: flex; flex-direction: column; background: rgba(11,13,18,.82); backdrop-filter: blur(6px); z-index: 2; }
  .term-caption { position: relative; z-index: 2; width: 80vw; margin-top: 14px; font-family: var(--mono); font-size: 13px; color: var(--term-dim); text-align: center; line-height: 1.6; }
  .term-caption b { color: var(--accent-soft); font-weight: 500; }
  .term-page .term-body { flex: 1; height: auto; font-size: 14px; }
  .term-page nav .wrap { height: 52px; }
  .term-page .input-row { border-top: 1px solid rgba(255,255,255,.05); padding-top: 12px; }
  .term-page .term-chrome .spacer { flex: 1; }
  .term-page .term-chrome a { font-size: 12px; color: var(--term-dim); transition: color .16s; }
  .term-page .term-chrome a:hover { color: var(--accent-soft); }

  /* ---------- about-me page ---------- */
  .page-head { padding: 64px 0 28px; }
  .page-head h1 { font-size: 46px; letter-spacing: -1.4px; line-height: 1.1; margin-bottom: 12px; }
  .page-head p { color: var(--muted); font-size: 17px; max-width: 56ch; }
  .photo-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; margin-bottom: 18px; }
  .photo { position: relative; display: block; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); aspect-ratio: 4 / 3; background: var(--card); transition: border-color .2s, transform .2s; }
  .photo img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .6s cubic-bezier(.22,.61,.36,1); }
  .photo:hover { border-color: rgba(255,59,59,.35); transform: translateY(-3px); }
  .photo:hover img { transform: scale(1.04); }
  .photo span { position: absolute; left: 14px; bottom: 12px; font-family: var(--mono); font-size: 12px; color: var(--ink); padding: 5px 9px; border-radius: 6px; background: rgba(10,11,14,.7); backdrop-filter: blur(4px); }
  .setup-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
  .setup-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 22px 24px; transition: border-color .2s, transform .2s, background .2s; }
  .setup-card:hover { border-color: rgba(255,59,59,.35); background: var(--card-hover); transform: translateY(-3px); }
  .setup-card .cat { font-family: var(--mono); font-size: 11px; color: var(--accent); letter-spacing: .5px; text-transform: uppercase; margin-bottom: 10px; }
  .setup-card h3 { font-size: 17px; margin-bottom: 8px; letter-spacing: -.2px; }
  .setup-card ul { list-style: none; }
  .setup-card li { color: var(--muted); font-size: 14px; padding: 5px 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; }
  .setup-card li:last-child { border: none; }
  .setup-card li b { color: var(--ink); font-weight: 500; }
  .setup-card .note { color: var(--term-dim); font-size: 13px; margin-top: 10px; font-family: var(--mono); }
  .setup-card.wide { grid-column: 1 / -1; }
  .spec-row { display: flex; flex-wrap: wrap; gap: 10px; }
  .spec { font-family: var(--mono); font-size: 13px; padding: 8px 12px; border-radius: 8px; background: rgba(255,255,255,.04); border: 1px solid var(--line); }
  .spec b { color: var(--accent-soft); font-weight: 500; }
  .empty { border: 1px dashed var(--line); border-radius: 14px; padding: 40px; text-align: center; color: var(--term-dim); font-family: var(--mono); font-size: 13px; }
  .pack { display: flex; flex-direction: column; }
  .pack .proj-media { height: 160px; }
  .pack .dl { margin-top: 14px; align-self: flex-start; }

  /* ---------- project detail pages ---------- */
  .proj-hero { padding: 40px 0 20px; }
  .proj-hero .back { font-family: var(--mono); font-size: 13px; color: var(--muted); display: inline-block; margin-bottom: 22px; transition: color .16s; }
  .proj-hero .back:hover { color: var(--accent-soft); }
  .proj-hero-media { height: 300px; border-radius: 16px; border: 1px solid var(--line); overflow: hidden; position: relative; display: flex; align-items: center; justify-content: center;
    background: radial-gradient(ellipse at center, rgba(255,255,255,.04), transparent 70%), var(--card); margin-bottom: 30px; }
  .proj-hero-media img { max-height: 60%; max-width: 60%; object-fit: contain; filter: drop-shadow(0 16px 32px rgba(0,0,0,.6)); position: relative; }
  .proj-hero-media.bg { background-size: cover; background-position: center; }
  .proj-hero-media.bg::before { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(10,11,14,.2), rgba(10,11,14,.85)); }
  .proj-hero-media.cp { background: radial-gradient(circle at 50% 60%, rgba(46,230,255,.18), transparent 62%), var(--card); }
  .proj-hero-media.wbio { background: radial-gradient(circle at 50% 60%, rgba(155,123,255,.22), transparent 62%), var(--card); }
  .proj-hero-media.wbio img { max-height: 60%; }
  .proj-hero-media.cover video { width: 100%; height: 100%; object-fit: cover; }
  .proj-hero-text .proj-top { margin-bottom: 14px; }
  .proj-hero h1 { font-size: 46px; letter-spacing: -1.4px; line-height: 1.1; margin-bottom: 14px; }
  .proj-hero .intro { color: var(--muted); font-size: 18px; max-width: 60ch; margin-bottom: 22px; }
  .proj-layout { display: grid; grid-template-columns: 1.4fr 1fr; gap: 40px; align-items: start; }
  .prose h2 { font-size: 22px; letter-spacing: -.4px; margin: 0 0 10px; }
  .prose p { color: var(--muted); font-size: 16px; line-height: 1.65; margin-bottom: 30px; max-width: 62ch; }
  .link-list { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }
  .link-list a { font-family: var(--mono); font-size: 13px; padding: 11px 14px; border-radius: 10px; background: var(--card); border: 1px solid var(--line); transition: border-color .2s, color .2s; }
  .link-list a:hover { border-color: var(--accent); color: var(--accent-soft); }
  @media (max-width: 860px) { .proj-layout { grid-template-columns: 1fr; } .proj-hero-media { height: 200px; } .proj-hero h1 { font-size: 34px; } }

  /* ---------- language toggle + RTL ---------- */
  .lang-toggle { display: inline-flex; align-items: center; gap: 6px; margin-inline-start: 22px; padding: 5px 10px; border-radius: 8px; border: 1px solid var(--line); background: transparent; color: var(--muted); font-family: var(--mono); font-size: 12px; cursor: pointer; transition: border-color .16s, color .16s; }
  .lang-toggle b { color: var(--ink); font-weight: 600; }
  .lang-toggle span { opacity: .55; }
  .lang-toggle:hover { border-color: var(--accent); color: var(--accent-soft); }
  html.fa body { font-family: var(--fa); }
  html.fa .hero h1, html.fa .page-head h1, html.fa .proj-hero h1, html.fa h2, html.fa h3 { letter-spacing: 0; }
  html.fa .hero h1 { font-size: 46px; }
  html.fa .kicker, html.fa .logo, html.fa .foot-links, html.fa .proj-tag, html.fa .proj-meta, html.fa .stack-box, html.fa .spec, html.fa .setup-card .cat, html.fa .setup-card .note, html.fa .empty, html.fa .link-list a, html.fa .photo span { font-family: var(--fa); }
  html.fa .terminal, html.fa .term-body, html.fa .input-row, html.fa .term-chrome, html.fa .win.terminal { direction: ltr; text-align: left; }
  html.fa .logo { direction: ltr; unicode-bidi: isolate; }
  html.fa .role, html.fa .role .typed { font-family: var(--fa); }
  html.fa .term-body .line.fa { direction: rtl; text-align: right; }
  .line.fa span:not(.wd):not(.emo) { unicode-bidi: plaintext; }   /* every span picks its own direction, so /commands inside Persian lines keep the / in front (nested spans too) */
  html.fa .proj h3 { text-align: right; }                       /* dir=auto keeps Latin titles LTR; still hug the right edge */
  .proj-meta span { unicode-bidi: isolate; }                    /* each #tag is its own LTR run, so the # never jumps */
  html.fa .proj::after { left: auto; right: 0; background: linear-gradient(270deg, var(--accent), transparent); }
  html.fa .line.assistant { border-left: none; border-right: 2px solid var(--accent); border-radius: 6px 0 0 6px; }
  html.fa .line.assistant:not(.fa) { direction: ltr; text-align: left; border-right: none; border-left: 2px solid var(--accent); border-radius: 0 6px 6px 0; }
  @media (max-width: 860px) { .lang-toggle { margin-inline-start: 8px; } }

  /* ---------- lightbox (in-site image viewer, see fx.js) ---------- */
  html.lb-open { overflow: hidden; }
  #lightbox { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 56px 72px; opacity: 0; transition: opacity .24s ease; }
  #lightbox[hidden] { display: none; }
  #lightbox.on { opacity: 1; }
  #lightbox .lb-back { position: absolute; inset: 0; background: rgba(6,7,10,.86); backdrop-filter: blur(10px) saturate(120%); cursor: zoom-out; }
  #lightbox .lb-fig { position: relative; z-index: 1; margin: 0; max-width: 100%; max-height: 100%; display: flex; flex-direction: column; align-items: center; gap: 12px;
    transform: scale(.94) translateY(10px); transition: transform .28s cubic-bezier(.22,.61,.36,1); }
  #lightbox.on .lb-fig { transform: none; }
  #lightbox img { max-width: 100%; max-height: calc(100vh - 150px); border-radius: 12px; border: 1px solid rgba(255,255,255,.08); box-shadow: 0 40px 100px -30px rgba(0,0,0,.95), 0 0 0 1px rgba(255,59,59,.08); transition: opacity .18s; cursor: pointer; }
  #lightbox img.swap { opacity: .35; }
  #lightbox.single img { cursor: default; }
  #lightbox figcaption { font-family: var(--mono); font-size: 12.5px; color: var(--muted); text-align: center; max-width: 70ch; }
  #lightbox figcaption[hidden] { display: none; }
  #lightbox button { position: absolute; z-index: 2; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: rgba(16,19,25,.85); color: var(--ink); font-size: 26px; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background .15s, border-color .15s, transform .15s; }
  #lightbox button:hover { background: rgba(255,59,59,.15); border-color: rgba(255,59,59,.45); transform: scale(1.06); }
  #lightbox .lb-x { top: 16px; right: 16px; }
  #lightbox .lb-prev { left: 16px; top: 50%; transform: translateY(-50%); }
  #lightbox .lb-next { right: 16px; top: 50%; transform: translateY(-50%); }
  #lightbox .lb-prev:hover, #lightbox .lb-next:hover { transform: translateY(-50%) scale(1.06); }
  #lightbox.single .lb-nav, #lightbox.single .lb-count { display: none; }
  #lightbox .lb-count { position: absolute; z-index: 2; left: 50%; bottom: 14px; transform: translateX(-50%); font-family: var(--mono); font-size: 12px; color: var(--term-dim); }
  @media (max-width: 640px) { #lightbox { padding: 64px 12px 48px; } #lightbox button { width: 38px; height: 38px; font-size: 22px; } #lightbox .lb-prev { left: 6px; } #lightbox .lb-next { right: 6px; } #lightbox img { max-height: calc(100vh - 130px); } }

/* dark, thin scrollbars (the browser default light bar stands out on this theme) */
* { scrollbar-width: thin; scrollbar-color: #262b36 transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: #262b36; border-radius: 4px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: #363c4a; background-clip: padding-box; border: 2px solid transparent; }
*::-webkit-scrollbar-corner { background: transparent; }
