/* =====================================================================
   Ahad Hajivand — 3D portfolio
   Dark, WebGL backdrop + CSS 3D charts. Mobile-first, LTR + RTL.
   ===================================================================== */

:root {
    --bg: #05060b;
    --bg-2: #0a0c16;
    --surface: rgba(255, 255, 255, .04);
    --surface-2: rgba(255, 255, 255, .07);
    --line: rgba(255, 255, 255, .10);
    --line-strong: rgba(255, 255, 255, .20);
    --ink: #f4f5fb;
    --ink-2: #b9bdd0;
    --ink-3: #8d92a9;
    --violet: #a78bfa;
    --cyan: #22d3ee;
    --pink: #f472b6;
    --yellow: #facc15;
    --green: #34d399;
    --danger: #fb7185;
    --grad: linear-gradient(115deg, var(--violet) 0%, var(--cyan) 50%, var(--pink) 100%);
    --radius-sm: 12px;
    --radius: 20px;
    --radius-lg: 28px;
    --gutter: 16px;
    --header-h: 64px;
    --dock-h: 68px;
    --ease-out: cubic-bezier(.16, 1, .3, 1);
    --font-display: 'Space Grotesk', 'Inter', system-ui, sans-serif;
    --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
    --z-canvas: 0;
    --z-content: 10;
    --z-header: 40;
    --z-dock: 45;
    --z-cursor: 90;
    --z-loader: 100;
}

html[lang="fa"] {
    --font-display: 'Vazirmatn', Tahoma, sans-serif;
    --font-body: 'Vazirmatn', Tahoma, sans-serif;
}

@media (min-width: 768px) {
    :root { --gutter: 32px; --header-h: 76px; }
}
@media (min-width: 1280px) {
    :root { --gutter: 48px; }
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--ink-2);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.65;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, p, ol, ul, figure { margin: 0; }
h1, h2, h3, h4 { color: var(--ink); font-family: var(--font-display); line-height: 1.12; }
ol, ul { padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
::selection { background: var(--violet); color: #0b0b14; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; border-radius: 6px; }
section[id] { scroll-margin-top: calc(var(--header-h) + 8px); }

.sr-only {
    position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
    position: fixed; top: 10px; inset-inline-start: 10px; z-index: 200;
    padding: 10px 16px; border-radius: 10px; background: var(--ink); color: var(--bg);
    transform: translateY(-160%); transition: transform .2s;
}
.skip-link:focus { transform: none; }

.container { width: 100%; max-width: 1240px; margin-inline: auto; padding-inline: var(--gutter); }
.text-gradient {
    background: var(--grad); background-size: 200% 100%;
    -webkit-background-clip: text; background-clip: text; color: transparent;
    animation: gradShift 8s ease-in-out infinite alternate;
}
@keyframes gradShift { to { background-position: 100% 0; } }

.glass {
    background: linear-gradient(160deg, rgba(255,255,255,.07), rgba(255,255,255,.02));
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 1px 0 rgba(255,255,255,.06) inset, 0 20px 50px -20px rgba(0,0,0,.6);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
}
.glass--strong { background: linear-gradient(160deg, rgba(20,22,38,.82), rgba(10,12,22,.72)); }
@media (max-width: 767px) {
    /* backdrop-filter is expensive on phones -- use opaque-ish fills instead */
    .glass { -webkit-backdrop-filter: none; backdrop-filter: none; background: linear-gradient(160deg, rgba(22,24,40,.9), rgba(12,14,26,.86)); }
}

/* ---------- backdrop ---------- */
#scene3d {
    position: fixed; inset: 0; width: 100%; height: 100%; z-index: var(--z-canvas);
    display: block; pointer-events: none; opacity: 0; transition: opacity 1.4s ease;
}
#scene3d.is-ready { opacity: 1; }
.backdrop-fallback {
    position: fixed; inset: 0; z-index: var(--z-canvas); pointer-events: none;
    background:
        radial-gradient(60vmax 50vmax at 85% 10%, rgba(167,139,250,.18), transparent 60%),
        radial-gradient(50vmax 40vmax at 0% 90%, rgba(34,211,238,.12), transparent 60%),
        radial-gradient(40vmax 30vmax at 50% 50%, rgba(244,114,182,.06), transparent 60%);
}
.noise {
    position: fixed; inset: 0; z-index: 1; pointer-events: none; opacity: .05; mix-blend-mode: overlay;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
main, .site-footer, .ribbon, .band { position: relative; z-index: var(--z-content); }

/* ---------- loader ---------- */
#loader {
    position: fixed; inset: 0; z-index: var(--z-loader); background: var(--bg);
    display: grid; place-items: center;
    clip-path: inset(0 0 0 0); transition: clip-path 1s var(--ease-out), visibility 0s 1s;
}
#loader.is-done { clip-path: inset(0 0 100% 0); visibility: hidden; }
html:not(.js) #loader { display: none; }
.loader__inner { display: grid; justify-items: center; gap: 14px; width: min(260px, 70vw); }
.loader__logo { font-family: var(--font-display); font-size: 40px; font-weight: 700; color: var(--ink); }
.loader__logo i, .brand__text i { font-style: normal; color: var(--cyan); }
.loader__count { font-family: var(--font-mono); font-size: 13px; color: var(--ink-3); }
.loader__bar { width: 100%; height: 2px; background: var(--line); border-radius: 2px; overflow: hidden; }
.loader__bar span { display: block; height: 100%; width: 0; background: var(--grad); }

/* ---------- scroll progress + cursor ---------- */
.scroll-progress { position: fixed; top: 0; inset-inline: 0; height: 2px; z-index: calc(var(--z-header) + 1); pointer-events: none; }
.scroll-progress span { display: block; height: 100%; background: var(--grad); transform: scaleX(0); transform-origin: left; }
[dir="rtl"] .scroll-progress span { transform-origin: right; }

.cursor { display: none; }
@media (hover: hover) and (pointer: fine) {
    .cursor { display: block; position: fixed; inset: 0; pointer-events: none; z-index: var(--z-cursor); }
    .cursor__dot, .cursor__ring {
        position: fixed; top: 0; left: 0; border-radius: 50%; pointer-events: none;
        transform: translate3d(-100px, -100px, 0); will-change: transform;
    }
    .cursor__dot { width: 6px; height: 6px; margin: -3px 0 0 -3px; background: var(--ink); }
    .cursor__ring {
        width: 36px; height: 36px; margin: -18px 0 0 -18px; border: 1px solid rgba(255,255,255,.45);
        transition: width .3s var(--ease-out), height .3s var(--ease-out), margin .3s var(--ease-out), background .3s, border-color .3s;
    }
    .cursor.is-hover .cursor__ring { width: 64px; height: 64px; margin: -32px 0 0 -32px; background: rgba(167,139,250,.12); border-color: var(--violet); }
}

/* ---------- header ---------- */
.site-header {
    position: fixed; top: 0; inset-inline: 0; z-index: var(--z-header);
    height: var(--header-h);
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding-inline: var(--gutter); padding-top: env(safe-area-inset-top);
    transition: background .4s, border-color .4s, transform .5s var(--ease-out);
    border-bottom: 1px solid transparent;
}
.site-header.is-scrolled {
    background: rgba(5,6,11,.72); border-color: var(--line);
    -webkit-backdrop-filter: blur(14px) saturate(140%); backdrop-filter: blur(14px) saturate(140%);
}
.site-header.is-hidden { transform: translateY(-100%); }
.brand { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; }
.brand__mark svg { width: 30px; height: 30px; display: block; }
.brand__text { font-family: var(--font-display); font-weight: 700; font-size: 20px; color: var(--ink); letter-spacing: -.01em; }

.nav-pill {
    display: none; position: relative; align-items: center; gap: 2px; padding: 5px;
    border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.04);
    -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.nav-pill a {
    position: relative; z-index: 1; padding: 8px 16px; border-radius: 999px; font-size: 14px; font-weight: 500;
    color: var(--ink-2); transition: color .25s;
}
.nav-pill a:hover, .nav-pill a.is-active { color: var(--ink); }
.nav-pill__indicator {
    position: absolute; top: 5px; bottom: 5px; left: 0; width: 0; border-radius: 999px;
    background: rgba(255,255,255,.1); border: 1px solid var(--line-strong);
    transition: transform .5s var(--ease-out), width .5s var(--ease-out), opacity .3s; opacity: 0;
}
.header-actions { display: flex; align-items: center; gap: 10px; }
.lang-switch {
    display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px;
    border: 1px solid var(--line); border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--ink);
    transition: border-color .25s, background .25s;
}
.lang-switch:hover { border-color: var(--line-strong); background: var(--surface-2); }
.header-actions .header-cta { display: none; }
@media (min-width: 1024px) {
    .nav-pill { display: inline-flex; }
    .header-actions .header-cta { display: inline-flex; }
}

/* ---------- mobile dock ---------- */
.dock {
    position: fixed; z-index: var(--z-dock);
    inset-inline: 12px; bottom: calc(10px + env(safe-area-inset-bottom));
    height: var(--dock-h); padding: 6px;
    display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px;
    background: rgba(12,14,26,.86); border: 1px solid var(--line-strong); border-radius: 22px;
    -webkit-backdrop-filter: blur(16px) saturate(150%); backdrop-filter: blur(16px) saturate(150%);
    box-shadow: 0 18px 40px -12px rgba(0,0,0,.8);
    transform: translateY(140%); transition: transform .6s var(--ease-out);
}
.dock.is-visible { transform: none; }
.dock a {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    border-radius: 16px; font-size: 11px; font-weight: 600; color: var(--ink-3);
    touch-action: manipulation; transition: color .25s, background .25s;
}
.dock a i { font-size: 21px; line-height: 1; transition: transform .35s var(--ease-out); }
.dock a.is-active { color: var(--ink); background: rgba(255,255,255,.08); }
.dock a.is-active i { transform: translateY(-2px); color: var(--cyan); }
.dock a:active { background: rgba(255,255,255,.12); }
@media (min-width: 1024px) { .dock { display: none; } }
@media (max-width: 1023px) {
    body { padding-bottom: calc(var(--dock-h) + 20px + env(safe-area-inset-bottom)); }
}

/* ---------- buttons, chips, pills ---------- */
.btn {
    position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 10px;
    min-height: 52px; padding: 0 26px; border-radius: 999px;
    font-weight: 600; font-size: 15px; white-space: nowrap; touch-action: manipulation;
    transition: transform .2s var(--ease-out), box-shadow .3s, background .3s, border-color .3s;
}
.btn i { font-size: 18px; }
.btn--sm { min-height: 40px; padding: 0 18px; font-size: 14px; }
.btn--block { width: 100%; }
.btn--primary { color: #0a0b14; background: var(--grad); background-size: 160% 100%; box-shadow: 0 10px 30px -10px rgba(167,139,250,.6); }
.btn--primary:hover { background-position: 100% 0; box-shadow: 0 14px 40px -10px rgba(34,211,238,.6); }
.btn--ghost { color: var(--ink); border: 1px solid var(--line-strong); background: rgba(255,255,255,.04); }
.btn--ghost:hover { background: rgba(255,255,255,.09); }
.btn:active { transform: scale(.97); }
.btn[aria-busy="true"] { opacity: .7; pointer-events: none; }

.pill {
    display: inline-flex; align-items: center; gap: 10px; padding: 8px 14px; border-radius: 999px;
    border: 1px solid var(--line); background: rgba(255,255,255,.04); font-size: 13px; color: var(--ink-2);
}
.pill__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 0 rgba(52,211,153,.6); animation: ping 2s infinite; }
@keyframes ping { 70% { box-shadow: 0 0 0 9px rgba(52,211,153,0); } 100% { box-shadow: 0 0 0 0 rgba(52,211,153,0); } }

.chip {
    display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 16px; border-radius: 999px;
    border: 1px solid var(--line); background: rgba(255,255,255,.03); font-size: 14px; font-weight: 500; color: var(--ink-2);
    white-space: nowrap; transition: background .25s, color .25s, border-color .25s;
}
.chip b { font-weight: 600; font-size: 12px; color: var(--ink-3); }
.chip:hover { border-color: var(--line-strong); color: var(--ink); }
.chip.is-active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip.is-active b { color: #3b3f55; }
.chip--sm { min-height: 26px; padding: 0 10px; font-size: 12px; }

.icon-btn {
    display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
    border: 1px solid var(--line); color: var(--ink); font-size: 18px; background: rgba(255,255,255,.03);
    transition: background .25s, border-color .25s, transform .25s var(--ease-out);
}
.icon-btn:hover { background: var(--ink); color: var(--bg); border-color: var(--ink); transform: translateY(-2px); }

/* ---------- typography helpers ---------- */
.section { padding-block: 96px; }
@media (min-width: 1024px) { .section { padding-block: 150px; } }
.section-head { max-width: 760px; margin-bottom: 40px; }
@media (min-width: 1024px) { .section-head { margin-bottom: 64px; } }
.eyebrow {
    display: inline-flex; align-items: center; gap: 12px; margin-bottom: 18px;
    font-size: 13px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-2);
}
html[lang="fa"] .eyebrow { letter-spacing: 0; font-size: 14px; }
.eyebrow span {
    font-family: var(--font-mono); font-size: 12px; padding: 3px 9px; border-radius: 999px;
    border: 1px solid var(--line-strong); color: var(--cyan); letter-spacing: 0;
}
.h2 { font-size: clamp(30px, 7vw, 64px); font-weight: 700; letter-spacing: -.025em; line-height: 1.06; text-wrap: balance; }
html[lang="fa"] .h2 { letter-spacing: 0; line-height: 1.3; font-weight: 800; }
.section-lead { margin-top: 18px; font-size: clamp(16px, 2.2vw, 19px); color: var(--ink-2); max-width: 60ch; }
[data-split] .w { display: inline-block; overflow: hidden; vertical-align: top; padding-bottom: .08em; margin-bottom: -.08em; }
[data-split] .w > span { display: inline-block; will-change: transform; }

/* ---------- HERO ---------- */
.hero {
    position: relative; min-height: 100svh;
    display: flex; flex-direction: column; justify-content: center;
    padding-top: calc(var(--header-h) + 32px); padding-bottom: 96px;
}
.hero::after { /* legibility scrim over the particle field on small screens */
    content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
    background: radial-gradient(120% 70% at 50% 45%, rgba(5,6,11,.55), transparent 70%);
}
.hero__grid { display: grid; gap: 48px; align-items: center; }
.hero__copy { display: grid; justify-items: start; gap: 0; }
.hero__badge { margin-bottom: 26px; }
.hero__greeting { font-family: var(--font-mono); font-size: 15px; color: var(--cyan); margin-bottom: 6px; }
.hero__title {
    font-size: clamp(56px, 17vw, 168px); font-weight: 700; line-height: .9; letter-spacing: -.045em;
    margin-bottom: 26px;
}
html[lang="fa"] .hero__title { font-size: clamp(56px, 17vw, 150px); letter-spacing: 0; line-height: 1.15; font-weight: 900; }
.hero__title .line { display: block; overflow: hidden; padding-bottom: .06em; }
.hero__title .line > span { display: inline-block; }
.hero__roles {
    display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; margin-bottom: 16px;
    font-family: var(--font-display); font-size: clamp(20px, 5vw, 30px); font-weight: 600; color: var(--ink);
}
.hero__roles-prefix { color: var(--ink-3); font-weight: 500; }
.typewriter { position: relative; color: var(--ink); min-height: 1.2em; }
.typewriter::after {
    content: ""; display: inline-block; width: 3px; height: .95em; margin-inline-start: 4px; vertical-align: -.1em;
    background: var(--cyan); animation: blink 1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }
.hero__lead { max-width: 52ch; font-size: clamp(16px, 2.3vw, 19px); color: var(--ink-2); margin-bottom: 34px; }
.hero__ctas { display: flex; flex-wrap: wrap; gap: 12px; width: 100%; }
@media (max-width: 479px) {
    .hero__ctas .btn { flex: 1 1 100%; }
}

.hero__visual { display: none; position: relative; perspective: 1200px; }
@media (min-width: 1024px) {
    .hero__grid { grid-template-columns: 1.15fr .85fr; }
    .hero__visual { display: block; height: 460px; }
    .hero::after { background: linear-gradient(90deg, rgba(5,6,11,.6), transparent 60%); }
    [dir="rtl"] .hero::after { background: linear-gradient(-90deg, rgba(5,6,11,.6), transparent 60%); }
}
.code-card {
    position: absolute; top: 50%; inset-inline-end: 0; width: min(440px, 100%);
    transform: translateY(-50%) rotateY(-14deg) rotateX(6deg); transform-style: preserve-3d;
    border-radius: 18px; overflow: hidden;
    background: linear-gradient(160deg, rgba(23,25,44,.9), rgba(10,11,22,.85));
    border: 1px solid var(--line-strong);
    box-shadow: 0 40px 80px -30px rgba(0,0,0,.9), 0 0 0 1px rgba(167,139,250,.1), 0 0 80px -20px rgba(167,139,250,.35);
    -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
[dir="rtl"] .code-card { transform: translateY(-50%) rotateY(14deg) rotateX(6deg); }
.code-card__bar { display: flex; align-items: center; gap: 7px; padding: 12px 16px; border-bottom: 1px solid var(--line); direction: ltr; }
.code-card__bar i { width: 11px; height: 11px; border-radius: 50%; background: #ff5f57; }
.code-card__bar i:nth-child(2) { background: #febc2e; }
.code-card__bar i:nth-child(3) { background: #28c840; }
.code-card__bar span { margin-left: 10px; font-family: var(--font-mono); font-size: 12px; color: var(--ink-3); }
.code-card__body { margin: 0; padding: 18px 20px 22px; font-family: var(--font-mono); font-size: 13px; line-height: 1.75; color: #cfd3e6; text-align: left; overflow: hidden; }
.code-card .k { color: #c792ea; }
.code-card .c { color: #ffcb6b; }
.code-card .v { color: #82aaff; }
.code-card .s { color: #c3e88d; }
.code-card .f { color: #22d3ee; }
.caret { display: inline-block; width: 8px; height: 15px; margin-left: 2px; vertical-align: -2px; background: var(--cyan); animation: blink 1s steps(1) infinite; }
.orbit-chip {
    position: absolute; display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: 12px;
    font-size: 13px; font-weight: 600; color: var(--ink);
    background: rgba(18,20,36,.85); border: 1px solid var(--line-strong);
    box-shadow: 0 16px 30px -12px rgba(0,0,0,.8);
    animation: floatY 6s ease-in-out infinite;
}
.orbit-chip i { color: var(--cyan); font-size: 16px; }
.orbit-chip--a { top: 4%; inset-inline-start: 10%; }
.orbit-chip--b { bottom: 6%; inset-inline-start: 2%; animation-delay: -2s; }
.orbit-chip--b i { color: var(--pink); }
.orbit-chip--c { bottom: 0; inset-inline-end: 6%; animation-delay: -4s; }
.orbit-chip--c i { color: var(--violet); }
@keyframes floatY { 50% { transform: translateY(-14px); } }

.scroll-cue {
    position: absolute; bottom: 28px; left: 50%; transform: translateX(-50%);
    display: none; flex-direction: column; align-items: center; gap: 8px;
    font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--ink-3);
}
.scroll-cue__mouse { width: 24px; height: 38px; border: 1.5px solid var(--line-strong); border-radius: 14px; display: flex; justify-content: center; padding-top: 7px; }
.scroll-cue__mouse span { width: 3px; height: 8px; border-radius: 3px; background: var(--ink); animation: wheel 1.8s var(--ease-out) infinite; }
@keyframes wheel { 0% { transform: translateY(0); opacity: 1; } 70% { transform: translateY(12px); opacity: 0; } 100% { opacity: 0; } }
@media (min-width: 768px) and (min-height: 700px) { .scroll-cue { display: flex; } }

/* ---------- ribbon ---------- */
.ribbon { padding-block: 10px; overflow: hidden; }
.ribbon__row {
    transform: rotate(-2.5deg) scale(1.06); background: rgba(255,255,255,.03);
    border-block: 1px solid var(--line); padding-block: 18px;
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent);
    mask-image: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent);
}
.ribbon__track, .band__track { display: flex; width: max-content; animation: marquee 38s linear infinite; }
[dir="rtl"] .ribbon__track, [dir="rtl"] .band__track { animation-name: marqueeRtl; }
.ribbon__track span {
    display: inline-flex; align-items: center; gap: 28px; padding-inline: 14px;
    font-family: var(--font-display); font-size: clamp(18px, 3vw, 26px); font-weight: 600; color: var(--ink); white-space: nowrap;
    direction: ltr;
}
.ribbon__track i { font-style: normal; font-size: 14px; color: var(--violet); }
@keyframes marquee { to { transform: translateX(-50%); } }
@keyframes marqueeRtl { to { transform: translateX(50%); } }

/* ---------- stats ---------- */
.stats { display: grid; gap: 14px; padding-block: 56px 0; }
@media (min-width: 640px) { .stats { grid-template-columns: repeat(3, 1fr); gap: 20px; } }
.stat { position: relative; display: grid; justify-items: center; text-align: center; padding: 30px 20px; transform-style: preserve-3d; }
.stat__ring { width: 128px; height: 128px; transform: rotate(-90deg); }
[dir="rtl"] .stat__ring { transform: rotate(-90deg) scaleY(-1); }
.stat__ring-track { fill: none; stroke: rgba(255,255,255,.07); stroke-width: 6; }
.stat__ring-fill {
    fill: none; stroke: var(--cyan); stroke-width: 6; stroke-linecap: round;
    stroke-dasharray: 326.73; stroke-dashoffset: calc(326.73px * (1 - var(--ring, 1)));
    filter: drop-shadow(0 0 8px rgba(34,211,238,.5));
}
.stat:nth-child(2) .stat__ring-fill { stroke: var(--violet); filter: drop-shadow(0 0 8px rgba(167,139,250,.5)); }
.stat:nth-child(3) .stat__ring-fill { stroke: var(--pink); filter: drop-shadow(0 0 8px rgba(244,114,182,.5)); }
.stat__value {
    position: absolute; top: 30px; width: 128px; height: 128px; display: grid; place-items: center;
    font-family: var(--font-display); font-size: 36px; font-weight: 700; color: var(--ink);
    font-variant-numeric: tabular-nums; transform: translateZ(30px);
}
.stat__label { margin-top: 14px; font-size: 15px; font-weight: 500; color: var(--ink-2); }

/* ---------- about ---------- */
.about__grid { display: grid; gap: 56px; }
@media (min-width: 1024px) {
    .about__grid { grid-template-columns: 1.1fr .9fr; gap: 80px; align-items: start; }
    .about__head { position: sticky; top: calc(var(--header-h) + 40px); }
}
.about__body { margin-top: 26px; font-size: 17px; line-height: 1.85; max-width: 62ch; }
.about__links { display: flex; gap: 10px; margin-top: 30px; }

.timeline { position: relative; display: grid; gap: 18px; padding-inline-start: 28px; }
.timeline__line { position: absolute; top: 12px; bottom: 12px; inset-inline-start: 6px; width: 2px; background: var(--line); border-radius: 2px; overflow: hidden; }
.timeline__line span { display: block; width: 100%; height: 100%; background: linear-gradient(var(--violet), var(--cyan), var(--pink)); transform-origin: top; }
.timeline__item { position: relative; padding: 24px; }
.timeline__item::before {
    content: ""; position: absolute; top: 30px; inset-inline-start: -28px; width: 14px; height: 14px; border-radius: 50%;
    background: var(--bg); border: 2px solid var(--cyan); box-shadow: 0 0 12px rgba(34,211,238,.6);
}
.timeline__icon {
    display: inline-grid; place-items: center; width: 46px; height: 46px; border-radius: 14px; margin-bottom: 16px;
    background: linear-gradient(140deg, rgba(167,139,250,.25), rgba(34,211,238,.15)); border: 1px solid var(--line-strong);
    font-size: 22px; color: var(--ink);
}
.timeline__item h3 { font-size: 19px; font-weight: 600; }
.timeline__item h3 small { font-family: var(--font-body); font-size: 14px; font-weight: 400; color: var(--ink-3); }
.timeline__item p { margin-top: 8px; font-size: 15px; color: var(--ink-2); }

/* ---------- skills / charts ---------- */
.skills__grid { display: grid; gap: 18px; }
@media (min-width: 1024px) {
    .skills__grid { grid-template-columns: 1.35fr 1fr; grid-template-areas: "bars donut" "areas donut"; gap: 22px; }
    .skills__bars { grid-area: bars; }
    .skills__donut { grid-area: donut; }
    .skills__areas { grid-area: areas; }
}
.chart-card { padding: 22px; border-radius: var(--radius-lg); overflow: hidden; }
@media (min-width: 768px) { .chart-card { padding: 30px; } }
.chart-card__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; font-family: var(--font-display); font-size: 17px; font-weight: 600; color: var(--ink); }
.chart-card__hint { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-body); font-size: 12px; font-weight: 500; color: var(--ink-3); }

/* 3D bar chart */
.chart3d {
    --bw: 24px; --ch: 190px;
    position: relative; height: calc(var(--ch) + 120px); perspective: 900px; perspective-origin: 50% 30%;
    cursor: grab; touch-action: pan-y; user-select: none; -webkit-user-select: none;
}
.chart3d:active { cursor: grabbing; }
@media (min-width: 480px) { .chart3d { --bw: 30px; --ch: 210px; } }
@media (min-width: 1024px) { .chart3d { --bw: 36px; --ch: 240px; } }
.chart3d__scene {
    --rx: -16deg; --ry: -26deg;
    position: absolute; left: 6%; right: 6%; bottom: 66px; height: var(--ch);
    transform-style: preserve-3d; transform: rotateX(var(--rx)) rotateY(var(--ry));
    will-change: transform;
}
.chart3d__floor {
    position: absolute; left: -16px; right: -16px; bottom: 0; height: 140px;
    transform-origin: bottom center; transform: translateZ(70px) rotateX(90deg);
    background:
        linear-gradient(rgba(167,139,250,.18) 1px, transparent 1px) 0 0 / 100% 20px,
        linear-gradient(90deg, rgba(167,139,250,.18) 1px, transparent 1px) 0 0 / 20px 100%,
        radial-gradient(closest-side, rgba(34,211,238,.18), transparent);
    border: 1px solid rgba(167,139,250,.25); border-radius: 6px;
}
.chart3d__wall { position: absolute; inset: 0 -16px; transform: translateZ(-40px); }
.chart3d__wall span { position: absolute; left: 0; right: 0; height: 0; border-top: 1px dashed rgba(255,255,255,.12); }
.chart3d__wall b { position: absolute; inset-inline-start: -4px; top: -9px; transform: translateX(-100%); font: 500 11px var(--font-mono); color: var(--ink-3); }
.chart3d__bars { position: absolute; inset: 0; display: flex; align-items: flex-end; justify-content: space-around; transform-style: preserve-3d; }
.bar3d { position: relative; height: 100%; width: var(--bw); transform-style: preserve-3d; }
.bar3d__prism {
    --c1: var(--violet); --c2: var(--cyan);
    position: absolute; bottom: 0; left: 0; width: var(--bw); height: calc(var(--v) * 1%);
    transform-style: preserve-3d; transform-origin: bottom center;
}
.bar3d:nth-child(3n+2) .bar3d__prism { --c1: var(--cyan); --c2: var(--pink); }
.bar3d:nth-child(3n) .bar3d__prism { --c1: var(--pink); --c2: var(--violet); }
.bar3d__prism .f { position: absolute; display: block; backface-visibility: hidden; }
.f--front, .f--back { inset: 0; }
.f--front { transform: translateZ(calc(var(--bw) / 2)); background: linear-gradient(to top, color-mix(in srgb, var(--c1) 55%, #0b0b18), var(--c2)); }
.f--back { transform: rotateY(180deg) translateZ(calc(var(--bw) / 2)); background: color-mix(in srgb, var(--c1) 40%, #0b0b18); }
.f--left, .f--right { top: 0; bottom: 0; left: 0; width: var(--bw); }
.f--right { transform: rotateY(90deg) translateZ(calc(var(--bw) / 2)); background: linear-gradient(to top, color-mix(in srgb, var(--c1) 35%, #06060e), color-mix(in srgb, var(--c2) 60%, #06060e)); }
.f--left { transform: rotateY(-90deg) translateZ(calc(var(--bw) / 2)); background: linear-gradient(to top, color-mix(in srgb, var(--c1) 35%, #06060e), color-mix(in srgb, var(--c2) 60%, #06060e)); }
.f--top { top: 0; left: 0; width: var(--bw); height: var(--bw); transform-origin: top center; transform: translateZ(calc(var(--bw) / -2)) rotateX(90deg); background: color-mix(in srgb, var(--c2) 80%, #fff); box-shadow: 0 0 24px var(--c2); }
@supports not (background: color-mix(in srgb, red 50%, blue)) {
    .f--front { background: linear-gradient(to top, #4c3a8f, var(--c2)); }
    .f--back, .f--left, .f--right { background: #2a2350; }
    .f--top { background: var(--c2); }
}
.bar3d__value {
    position: absolute; left: 50%; bottom: calc(var(--v) * 1% + 12px); transform: translateX(-50%);
    font: 600 12px var(--font-mono); color: var(--ink); white-space: nowrap;
}
.bar3d__label {
    position: absolute; top: calc(100% + 14px); left: 50%; transform: translateX(-50%) translateZ(calc(var(--bw) / 2 + 40px));
    font: 500 11px var(--font-mono); color: var(--ink-2); white-space: nowrap;
}
@media (max-width: 639px) {
    .chart3d__scene { left: 14%; right: 4%; }
    [dir="rtl"] .chart3d__scene { left: 16%; right: 2%; }
    .bar3d__label { transform: translateZ(calc(var(--bw) / 2 + 40px)) rotate(-38deg); transform-origin: top right; left: auto; right: 50%; }
}

/* 3D donut */
.donut3d { position: relative; display: grid; place-items: center; height: 300px; padding-top: 70px; perspective: 900px; margin-bottom: 8px; }
@media (min-width: 1024px) { .donut3d { height: 420px; padding-top: 90px; } }
.donut3d__stage {
    position: relative; width: min(280px, 74vw); aspect-ratio: 1; transform-style: preserve-3d;
    transform: rotateX(58deg) rotateZ(var(--spin, -20deg));
}
.donut3d__layer { position: absolute; inset: 0; width: 100%; height: 100%; transform: translateZ(calc(var(--z) * 3px)); filter: brightness(.4); }
.donut3d__layer.is-top { filter: none; }
.donut3d__layer.is-top circle { transition: stroke-width .3s var(--ease-out), opacity .3s; }
.donut3d.has-focus .donut3d__layer.is-top circle { opacity: .35; }
.donut3d.has-focus .donut3d__layer.is-top circle.is-focus { opacity: 1; stroke-width: 40; }
.donut3d__center { position: absolute; top: 4px; left: 0; right: 0; display: flex; align-items: baseline; justify-content: center; gap: 10px; pointer-events: none; }
.donut3d__center strong { font-family: var(--font-display); font-size: 52px; font-weight: 700; line-height: 1; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.donut3d__center span { font-size: 14px; color: var(--ink-2); }
@media (min-width: 1024px) { .donut3d__center { top: 16px; } .donut3d__center strong { font-size: 64px; } }
.legend { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px; }
.legend li {
    display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 12px; border-radius: 12px;
    background: rgba(255,255,255,.03); border: 1px solid var(--line); font-size: 14px; color: var(--ink-2); cursor: default;
    transition: background .25s, border-color .25s;
}
.legend li:hover, .legend li.is-focus { background: rgba(255,255,255,.08); border-color: var(--line-strong); color: var(--ink); }
.legend i { width: 12px; height: 12px; border-radius: 4px; flex: none; }
.legend span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.legend b { font-family: var(--font-mono); font-weight: 600; color: var(--ink); }

/* extruded tubes */
.tubes { display: grid; gap: 22px; margin-top: 14px; }
.tube__head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 10px; }
.tube__name { font-weight: 600; color: var(--ink); font-size: 15px; }
.tube__name small { display: block; font-weight: 400; font-size: 13px; color: var(--ink-3); }
.tube__head b { font-family: var(--font-mono); color: var(--ink); font-size: 15px; font-variant-numeric: tabular-nums; }
.tube__track {
    position: relative; height: 16px; border-radius: 999px;
    background: linear-gradient(to bottom, rgba(0,0,0,.5), rgba(255,255,255,.06));
    box-shadow: inset 0 2px 4px rgba(0,0,0,.6), 0 1px 0 rgba(255,255,255,.06);
    overflow: hidden;
}
.tube__fill {
    position: absolute; inset-block: 2px; inset-inline-start: 2px; width: calc(100% - 4px); border-radius: 999px;
    background:
        linear-gradient(to bottom, rgba(255,255,255,.55), rgba(255,255,255,0) 45%, rgba(0,0,0,.25)),
        var(--grad);
    box-shadow: 0 0 18px rgba(34,211,238,.45);
    transform-origin: left;
}
[dir="rtl"] .tube__fill { transform-origin: right; }

/* ---------- services ---------- */
.services__grid { display: grid; gap: 16px; perspective: 1400px; }
@media (min-width: 768px) { .services__grid { grid-template-columns: repeat(2, 1fr); gap: 20px; } }
.service {
    --mx: 50%; --my: 50%;
    position: relative; padding: 28px; min-height: 240px; display: flex; flex-direction: column;
    transform-style: preserve-3d; overflow: hidden; isolation: isolate;
}
@media (min-width: 1024px) { .service { padding: 38px; min-height: 290px; } }
.service::before { /* pointer spotlight */
    content: ""; position: absolute; inset: 0; z-index: -1; opacity: 0; transition: opacity .4s;
    background: radial-gradient(400px circle at var(--mx) var(--my), rgba(167,139,250,.18), transparent 45%);
}
.service::after { /* glowing border that follows the pointer */
    content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1px; pointer-events: none; opacity: 0; transition: opacity .4s;
    background: radial-gradient(300px circle at var(--mx) var(--my), rgba(34,211,238,.9), transparent 40%);
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor;
    mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
}
.service:hover::before, .service:hover::after { opacity: 1; }
.service__num { position: absolute; top: 22px; inset-inline-end: 26px; font: 600 13px var(--font-mono); color: var(--ink-3); }
.service__icon {
    display: inline-grid; place-items: center; width: 60px; height: 60px; margin-bottom: auto; border-radius: 18px;
    font-size: 28px; color: #0a0b14; background: var(--grad); background-size: 200% 200%;
    box-shadow: 0 14px 30px -10px rgba(167,139,250,.7), inset 0 1px 0 rgba(255,255,255,.5);
    transform: translateZ(40px);
}
.service h3 { margin-top: 36px; font-size: clamp(20px, 2.4vw, 26px); font-weight: 600; transform: translateZ(28px); }
.service p { margin-top: 10px; color: var(--ink-2); font-size: 15px; transform: translateZ(18px); }

/* ---------- work / reel ---------- */
.work { padding-bottom: 40px; }
.work__head { display: grid; gap: 8px; }
.filters {
    display: flex; gap: 8px; margin-bottom: 30px; overflow-x: auto; scrollbar-width: none;
    margin-inline: calc(var(--gutter) * -1); padding-inline: var(--gutter); padding-bottom: 4px;
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 var(--gutter), #000 calc(100% - var(--gutter)), transparent);
    mask-image: linear-gradient(90deg, transparent, #000 var(--gutter), #000 calc(100% - var(--gutter)), transparent);
}
.filters::-webkit-scrollbar { display: none; }
@media (min-width: 1024px) { .filters { flex-wrap: wrap; overflow: visible; margin-inline: 0; padding-inline: 0; -webkit-mask-image: none; mask-image: none; } }

.reel__viewport {
    overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory; scrollbar-width: none;
    -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; perspective: 1200px;
}
.reel__viewport::-webkit-scrollbar { display: none; }
.reel__track { display: flex; gap: 16px; padding: 20px var(--gutter) 30px; width: max-content; transform-style: preserve-3d; }
.project-slot { flex: none; display: flex; width: min(82vw, 360px); scroll-snap-align: center; transform-style: preserve-3d; }
.project-slot[hidden] { display: none; }
.project {
    position: relative; width: 100%;
    display: flex; flex-direction: column; border-radius: var(--radius-lg); overflow: hidden;
    background: linear-gradient(170deg, rgba(24,26,44,.95), rgba(10,12,22,.95));
    border: 1px solid var(--line);
    box-shadow: 0 30px 60px -30px rgba(0,0,0,.9);
    transform-style: preserve-3d; will-change: transform;
    transition: border-color .3s;
}
.project:hover { border-color: var(--line-strong); }
.project__media {
    position: relative; aspect-ratio: 16 / 10; overflow: hidden;
    background:
        radial-gradient(80% 90% at 30% 20%, rgba(167,139,250,.25), transparent 60%),
        radial-gradient(70% 80% at 80% 100%, rgba(34,211,238,.2), transparent 60%),
        radial-gradient(45% 55% at 50% 45%, rgba(255,255,255,.16), transparent 70%),
        #0c0e1c;
}
.project__media::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, rgba(10,12,22,.9), transparent 45%); }
.project__media img { width: 100%; height: 100%; object-fit: contain; padding: 18px; transition: transform .8s var(--ease-out); }
.project:hover .project__media img { transform: scale(1.06); }
.project__index { position: absolute; z-index: 1; bottom: 12px; inset-inline-start: 16px; font: 700 40px/1 var(--font-display); color: rgba(255,255,255,.14); }
.project__body { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 20px 22px 24px; flex: 1; }
.project__body h3 { font-size: 22px; font-weight: 600; transition: color .25s; }
.project:hover h3 { color: var(--cyan); }
.project__body p { font-size: 14px; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.project__link { margin-top: auto; padding-top: 6px; display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 14px; color: var(--ink); }
.project__link i { transition: transform .3s var(--ease-out); }
.project:hover .project__link i { transform: translate(3px, -3px); }
[dir="rtl"] .project:hover .project__link i { transform: translate(-3px, -3px); }

.reel__controls { display: flex; align-items: center; gap: 16px; margin-top: 6px; }
.reel__hint { font-size: 13px; color: var(--ink-3); display: inline-flex; align-items: center; gap: 6px; }
.reel__hint i { font-size: 16px; }
.reel__progress { flex: 1; height: 2px; background: var(--line); border-radius: 2px; overflow: hidden; min-width: 40px; }
.reel__progress span { display: block; height: 100%; background: var(--grad); transform: scaleX(0); transform-origin: left; }
[dir="rtl"] .reel__progress span { transform-origin: right; }
.reel__buttons { display: flex; gap: 8px; }
.reel:not(.is-pinned) .hint-pinned, .reel.is-pinned .hint-swipe, .reel.is-pinned .reel__buttons { display: none; }
@media (min-width: 1024px) {
    .reel.is-pinned .reel__viewport { overflow: hidden; scroll-snap-type: none; }
    .reel__track { gap: 26px; }
    .project-slot { width: 400px; }
}

/* ---------- kinetic band ---------- */
.band { overflow: hidden; padding-block: 50px; }
.band__track { animation-duration: 30s; align-items: center; }
.band__track span {
    padding-inline: 28px; white-space: nowrap; font-family: var(--font-display); font-weight: 700;
    font-size: clamp(44px, 10vw, 130px); line-height: 1.1; letter-spacing: -.03em;
    color: transparent; -webkit-text-stroke: 1.2px rgba(255,255,255,.35);
}
html[lang="fa"] .band__track span { letter-spacing: 0; font-weight: 900; }
.band__track span:nth-of-type(2n) { color: var(--ink); -webkit-text-stroke: 0; }
.band__track i { font-style: normal; font-size: clamp(24px, 4vw, 48px); color: var(--violet); }

/* ---------- contact ---------- */
.contact__grid { display: grid; gap: 40px; }
@media (min-width: 1024px) { .contact__grid { grid-template-columns: 1fr 1fr; gap: 72px; align-items: start; } }
.contact__title { margin: 0; }
.contact__cards { display: grid; gap: 12px; margin-top: 32px; }
.contact-card { display: flex; align-items: center; gap: 16px; padding: 14px 18px; min-height: 72px; transition: transform .3s var(--ease-out), border-color .3s; }
.contact-card:hover { transform: translateY(-3px); border-color: var(--line-strong); }
.contact-card small { display: block; font-size: 12px; color: var(--ink-3); }
.contact-card b { display: block; color: var(--ink); font-weight: 600; font-size: 15px; overflow-wrap: anywhere; }
.contact-card__icon {
    flex: none; display: grid; place-items: center; width: 46px; height: 46px; border-radius: 14px; font-size: 21px; color: var(--ink);
    background: linear-gradient(140deg, rgba(167,139,250,.3), rgba(34,211,238,.18)); border: 1px solid var(--line-strong);
}
.contact-card__icon--wa { background: linear-gradient(140deg, rgba(52,211,153,.35), rgba(34,211,238,.15)); }

.form-card { padding: 24px; border-radius: var(--radius-lg); }
@media (min-width: 768px) { .form-card { padding: 36px; } }
.field { display: grid; gap: 8px; margin-bottom: 20px; }
.field-row { display: grid; gap: 0 16px; }
@media (min-width: 640px) { .field-row { grid-template-columns: 1fr 1fr; } }
.field label { font-size: 14px; font-weight: 600; color: var(--ink); }
.field label small { font-weight: 400; color: var(--ink-3); }
.req { color: var(--pink); }
.field input, .field textarea {
    width: 100%; min-height: 52px; padding: 14px 16px; border-radius: 14px;
    border: 1px solid var(--line-strong); background: rgba(5,6,11,.55); color: var(--ink);
    font: inherit; font-size: 16px; line-height: 1.5;
    transition: border-color .25s, box-shadow .25s, background .25s;
}
.field textarea { resize: vertical; min-height: 130px; }
.field input:hover, .field textarea:hover { border-color: rgba(255,255,255,.3); }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 0 4px rgba(34,211,238,.15); background: rgba(5,6,11,.8); }
.field__help { font-size: 13px; color: var(--ink-3); }
.field__error { font-size: 13px; color: var(--danger); display: flex; gap: 6px; align-items: center; }
.field__error::before { content: "\eca1"; font-family: remixicon; }
.has-error input, .has-error textarea { border-color: var(--danger); }
.alert { display: flex; align-items: center; gap: 10px; padding: 14px 16px; margin-bottom: 22px; border-radius: 14px; font-size: 15px; }
.alert i { font-size: 20px; }
.alert--success { background: rgba(52,211,153,.12); border: 1px solid rgba(52,211,153,.4); color: #a7f3d0; }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--line); padding-block: 28px; background: rgba(5,6,11,.6); }
.site-footer__inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 18px; }
.site-footer p { font-size: 14px; color: var(--ink-3); }
.site-footer b { color: var(--ink); }
.site-footer__social { display: flex; gap: 8px; }

/* ---------- initial states: only when JS + motion are available ----------
   Defaults above are the FINAL state, so the page is complete without JS,
   with reduced motion, or if a CDN script fails (the head script drops .motion). */
html.motion [data-reveal] { opacity: 0; transform: translateY(40px); }
html.motion [data-hero-fade] { opacity: 0; transform: translateY(24px); }
html.motion [data-hero-line] { transform: translateY(110%); }
html.motion [data-hero-card] { opacity: 0; }
html.motion .bar3d__prism { transform: scaleY(.001); }
html.motion .bar3d__value { opacity: 0; }
html.motion .tube__fill { transform: scaleX(0); }
html.motion .timeline__line span { transform: scaleY(0); }
html.motion .stat__ring-fill { stroke-dashoffset: 326.73px; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
