/* Vazirmatn, self-hosted (Google Fonts is unreliable from Iran). SIL OFL: static/fonts/OFL.txt */
@font-face {
  font-family: Vazirmatn;
  src: url("../fonts/Vazirmatn-wght.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #f5f6fb;
  --card: #ffffff;
  --text: #1b2130;
  --muted: #677086;
  --line: #e6e8f0;
  --soft: #eef0fb;
  --accent: #4f46e5;
  --accent-2: #7c3aed;
  --accent-soft: #eef0ff;
  --ok: #15803d; --ok-bg: #dcfce7;
  --warn: #a16207; --warn-bg: #fef3c7;
  --bad: #b91c1c; --bad-bg: #fee2e2;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 16px rgba(16, 24, 40, .06);
  --shadow-lg: 0 8px 30px rgba(79, 70, 229, .16);
  --radius: 18px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1120;
    --card: #161a2c;
    --text: #e6e8f2;
    --muted: #9aa2b8;
    --line: #262b42;
    --soft: #1d2238;
    --accent: #818cf8;
    --accent-2: #a78bfa;
    --accent-soft: #1f2442;
    --ok: #4ade80; --ok-bg: #12331f;
    --warn: #facc15; --warn-bg: #3a300d;
    --bad: #f87171; --bad-bg: #3b1418;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: Vazirmatn, Tahoma, sans-serif; line-height: 1.85;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 880px; margin: 0 auto; padding: 24px 16px 40px; }
.icon { width: 1.1em; height: 1.1em; flex: none; vertical-align: -0.18em; }
.hint { color: var(--muted); }

/* Cards */
section {
  position: relative; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 24px; margin-top: 20px; box-shadow: var(--shadow);
}
h2 { display: flex; align-items: center; gap: 10px; margin: 0 0 16px; font-size: 1.2rem; font-weight: 800; }
h2 .icon {
  width: 34px; height: 34px; padding: 7px; border-radius: 10px;
  background: var(--accent-soft); color: var(--accent);
}

/* Forms and buttons */
textarea, input, select {
  width: 100%; font: inherit; color: var(--text); background: var(--card);
  padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px;
  transition: border-color .15s, box-shadow .15s;
}
textarea:focus, input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
textarea { min-height: 120px; resize: vertical; }
/* Each line takes the direction of its own text: English right-to-left looked broken. */
textarea, input:not([type=checkbox]):not([type=radio]) { unicode-bidi: plaintext; text-align: start; }
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 600; cursor: pointer; border: 0; border-radius: 12px; padding: 9px 20px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
  transition: transform .15s, box-shadow .15s, opacity .15s; text-decoration: none;
}
button:hover, .btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-lg); text-decoration: none; }
button:disabled { opacity: .7; cursor: progress; transform: none; }
button.ghost, .btn.ghost { background: var(--accent-soft); color: var(--accent); }
button.ghost:hover, .btn.ghost:hover { box-shadow: none; }
button.danger { background: #dc2626; }
a.danger { color: var(--bad); }
.pill {
  background: var(--soft); color: var(--text); border: 1px solid var(--line);
  border-radius: 99px; padding: 6px 16px; font-weight: 500;
}
.pill:hover { box-shadow: none; border-color: var(--accent); color: var(--accent); }
.pill.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.pill.small { padding: 3px 12px; font-size: .85rem; }
.row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.row.between { justify-content: space-between; align-items: center; }
.row.between h2 { margin: 0; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-form input { flex: 1; min-width: 200px; width: auto; margin: 0; }

/* HTMX loading spinner (hidden until a request is in flight) */
.spinner {
  display: none; width: 1em; height: 1em; border-radius: 50%;
  border: 2px solid currentColor; border-top-color: transparent; animation: spin .7s linear infinite;
}
.htmx-request .spinner, .htmx-request.spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Hero */
.hero {
  position: relative; overflow: hidden; border-radius: 24px; margin-top: 4px;
  background: linear-gradient(135deg, #4338ca 0%, #6d28d9 55%, #9333ea 100%); color: #fff;
  box-shadow: var(--shadow-lg);
}
.hero::before, .hero::after {
  content: ""; position: absolute; border-radius: 50%; background: rgba(255, 255, 255, .08);
}
.hero::before { width: 320px; height: 320px; top: -140px; inset-inline-start: -80px; }
.hero::after { width: 220px; height: 220px; bottom: -110px; inset-inline-end: -40px; }
.hero-body { position: relative; text-align: center; padding: 40px 20px 32px; }
.avatar {
  width: 84px; height: 84px; margin: 0 auto 12px; border-radius: 50%;
  display: grid; place-items: center; font-size: 2.2rem; font-weight: 800;
  background: rgba(255, 255, 255, .16); border: 2px solid rgba(255, 255, 255, .35);
}
.hero h1 { margin: 0; font-size: clamp(1.7rem, 4vw, 2.3rem); font-weight: 900; line-height: 1.3; }
.hero .title { margin: 4px 0 0; font-size: 1.15rem; font-weight: 600; opacity: .95; }
.hero .headline { margin: 2px 0 0; opacity: .8; }
.chips, .socials, .cta { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 16px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 12px; border-radius: 99px;
  background: rgba(255, 255, 255, .14); color: #fff; font-size: .9rem;
}
a.chip:hover { background: rgba(255, 255, 255, .24); text-decoration: none; }
.socials a {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px;
  background: rgba(255, 255, 255, .14); color: #fff; transition: background .15s;
}
.socials a:hover { background: rgba(255, 255, 255, .28); }
.socials .icon { width: 20px; height: 20px; }
.cta { margin-top: 22px; }
.btn.light { background: #fff; color: #4338ca; }
.btn.outline { background: transparent; color: #fff; border: 1px solid rgba(255, 255, 255, .5); }

/* Sticky section nav */
.toc {
  position: sticky; top: 8px; z-index: 5; display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none;
  margin-top: 16px; padding: 6px; border-radius: 14px;
  background: color-mix(in srgb, var(--card) 85%, transparent); backdrop-filter: blur(10px);
  border: 1px solid var(--line); box-shadow: var(--shadow);
}
.toc::-webkit-scrollbar { display: none; }
.toc a { flex: none; padding: 4px 14px; border-radius: 10px; color: var(--muted); font-weight: 500; }
.toc a:hover { background: var(--soft); color: var(--text); text-decoration: none; }
.toc .ai-link { color: var(--accent); }

/* Resume content */
.about { white-space: pre-line; margin: 0; }
.company { display: block; color: var(--muted); font-size: .95rem; }
.date { color: var(--muted); font-size: .85rem; white-space: nowrap; direction: ltr; }
.date.current { color: var(--ok); font-weight: 600; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tags span {
  background: var(--accent-soft); color: var(--accent); border-radius: 8px;
  padding: 1px 10px; font-size: .82rem; font-weight: 500; direction: ltr;
}

.timeline { list-style: none; margin: 0; padding: 0; }
.exp { position: relative; padding-inline-start: 28px; padding-bottom: 22px; }
.exp:last-child { padding-bottom: 0; }
.exp::before {
  content: ""; position: absolute; inset-inline-start: 5px; top: 10px; bottom: -10px; width: 2px; background: var(--line);
}
.exp:last-child::before { display: none; }
.exp::after {
  content: ""; position: absolute; inset-inline-start: 0; top: 8px; width: 12px; height: 12px;
  border-radius: 50%; background: var(--card); border: 3px solid var(--accent);
}
.exp-head { display: flex; justify-content: space-between; gap: 4px 12px; flex-wrap: wrap; align-items: baseline; }
.exp-head b { font-size: 1.05rem; }
.exp ul, .proj ul { margin: 8px 0 0; padding-inline-start: 18px; }
.exp li::marker, .proj li::marker { color: var(--accent); }

.skill-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.skill-group { background: var(--soft); border-radius: 14px; padding: 12px 14px; }
.skill-group .tags { margin-top: 6px; }
.skill-group .tags span { background: var(--card); }

.personalize { background: var(--soft); border-radius: 14px; padding: 12px 14px; margin-bottom: 16px; }
.personalize .hint { margin: 0 0 8px; }
.personalize .row { margin-bottom: 8px; }
.role-note { display: flex; align-items: center; gap: 6px; color: var(--accent); margin: 0 0 12px; font-weight: 500; }
.role-note.muted { color: var(--muted); }
.projects { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.proj {
  display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 16px; padding: 16px;
  background: var(--card); transition: transform .15s, box-shadow .15s, border-color .15s;
}
.proj:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.proj.top { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.proj-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.proj-head b { font-size: 1.02rem; line-height: 1.5; }
.status {
  flex: none; font-size: .72rem; padding: 1px 8px; border-radius: 99px;
  background: var(--ok-bg); color: var(--ok); white-space: nowrap;
}
.proj p { margin: 8px 0 0; }
.proj details { margin-top: 6px; border: 0; padding: 0; }
.proj summary { color: var(--accent); font-size: .9rem; }
.proj .tags { margin-top: auto; padding-top: 12px; }
.proj-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.proj-links a {
  display: inline-flex; align-items: center; gap: 5px; font-size: .85rem;
  padding: 3px 10px; border-radius: 8px; border: 1px solid var(--line); color: var(--text);
}
.proj-links a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

.split { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 24px; }
.edu b { display: block; }
ul.plain { list-style: none; padding: 0; margin: 0; }
.langs li { display: flex; flex-direction: column; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.langs li:last-child { border: 0; }
.langs span { color: var(--muted); font-size: .92rem; }

/* AI sections */
section.ai { border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
section.ai::before {
  content: ""; position: absolute; inset: 0 0 auto; height: 4px; border-radius: var(--radius) var(--radius) 0 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}
.ai-badge {
  position: absolute; top: 20px; inset-inline-end: 20px; display: inline-flex; align-items: center; gap: 4px;
  font-size: .75rem; font-weight: 600; padding: 2px 10px; border-radius: 99px;
  background: var(--accent-soft); color: var(--accent);
}
.chat { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; max-height: 480px; overflow-y: auto; }
.chat:empty { display: none; }
.msg { padding: 10px 14px; border-radius: 16px; max-width: 85%; animation: pop .2s ease-out; }
.msg.me { align-self: flex-start; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border-end-start-radius: 4px; }
.msg.bot { align-self: flex-end; background: var(--soft); border-end-end-radius: 4px; }
.msg ul { margin: 4px 0 0; padding-inline-start: 18px; }
.msg p { margin: 0 0 4px; }
.verdict { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.verdict.yes { color: var(--ok); }
.verdict.no { color: var(--warn); }
.suggest { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
@keyframes pop { from { opacity: 0; transform: translateY(4px); } }

.fit-result { margin-top: 16px; animation: pop .2s ease-out; }
.fit-overall { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-weight: 600; }
.fit-overall b { padding: 2px 14px; border-radius: 99px; }
.fit-overall.strong b { background: var(--ok-bg); color: var(--ok); }
.fit-overall.medium b { background: var(--warn-bg); color: var(--warn); }
.fit-overall.weak b { background: var(--bad-bg); color: var(--bad); }
.reqs { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 6px; }
.reqs li { display: flex; align-items: flex-start; gap: 10px; padding: 8px 12px; border-radius: 12px; background: var(--soft); }
.reqs .mark {
  flex: none; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
  font-weight: 800; font-size: .85rem; margin-top: 2px;
}
.reqs .lvl2 .mark { background: var(--ok-bg); color: var(--ok); }
.reqs .lvl1 .mark { background: var(--warn-bg); color: var(--warn); }
.reqs .lvl0 .mark { background: var(--bad-bg); color: var(--bad); }

.quote { position: relative; text-align: center; margin: 32px 0 0; padding: 8px 24px; color: var(--muted); }
.quote .icon { width: 28px; height: 28px; color: var(--accent); opacity: .5; }
.quote p { margin: 4px 0; font-size: 1.1rem; font-style: italic; color: var(--text); }
.quote footer { font-weight: 600; }
.site-footer {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px;
  margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: .9rem;
}

/* Panel */
.panel-nav {
  display: flex; gap: 4px; flex-wrap: wrap; padding: 8px; background: var(--card);
  border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow);
}
.panel-nav a { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 10px; color: var(--muted); font-weight: 500; }
.panel-nav a:hover { background: var(--soft); color: var(--text); text-decoration: none; }
.panel-nav a.active { background: var(--accent-soft); color: var(--accent); }
.panel-nav .spacer { flex: 1; }
.flash { background: var(--ok-bg); color: var(--ok); border-radius: 12px; padding: 10px 14px; margin: 16px 0 0; font-weight: 500; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat {
  display: block; border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; color: var(--text);
  transition: border-color .15s, transform .15s;
}
.stat:hover { border-color: var(--accent); transform: translateY(-1px); text-decoration: none; }
.stat b { display: block; font-size: 1.5rem; font-weight: 800; overflow-wrap: break-word; line-height: 1.4; }
.stat.name b { font-size: 1.1rem; padding-top: 6px; }
.stat small { color: var(--muted); }
.items { width: 100%; border-collapse: collapse; }
.items td, .items th { padding: 10px 6px; border-bottom: 1px solid var(--line); vertical-align: top; text-align: start; }
.items tr:last-child td { border-bottom: 0; }
.items tr:hover td { background: color-mix(in srgb, var(--soft) 60%, transparent); }
.items .actions { text-align: end; white-space: nowrap; }
.items .actions a { margin-inline-start: 12px; }
.nowrap { white-space: nowrap; }
.panel-form > div { margin-bottom: 8px; }
.panel-form label { display: block; font-weight: 600; margin-bottom: 4px; }
.panel-form .helptext { display: block; color: var(--muted); font-size: .85rem; margin: -6px 0 8px; }
.panel-form input[type=checkbox] { width: auto; margin: 0 0 0 6px; accent-color: var(--accent); }
.panel-form div > div label, .panel-form ul label { font-weight: normal; display: inline; }
.panel-form fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; margin: 0 0 10px; }
.panel-form legend { font-weight: 600; padding: 0 4px; }
.errorlist { color: var(--bad); margin: 0 0 6px; padding: 0; list-style: none; }
details { border-bottom: 1px solid var(--line); padding: 8px 0; }
summary { cursor: pointer; }
pre { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--soft); padding: 10px; border-radius: 10px; font-size: .85rem; }
input[type=url], input[type=email] { direction: ltr; text-align: left; }

/* Panel: resume review */
.review tr > :first-child { border-inline-start: 3px solid transparent; padding-inline-start: 10px; }
.review tr.weak td:first-child { border-inline-start-color: var(--bad); }
.review tr.improvable td:first-child { border-inline-start-color: var(--warn); }
.grade { display: inline-block; border-radius: 99px; padding: 2px 12px; margin-inline-end: 6px; font-size: .9rem; font-weight: 600; }
.grade.weak { background: var(--bad-bg); color: var(--bad); }
.grade.improvable { background: var(--warn-bg); color: var(--warn); }
.grade.good { background: var(--ok-bg); color: var(--ok); }
.review th { font-weight: normal; color: var(--muted); font-size: .85rem; }
.review .check { text-align: center; font-weight: bold; width: 2.5em; }
.review .check.ok { color: var(--ok); }
.review .check.no { color: var(--bad); }
.review .missing { color: var(--warn); }
.review .evidence.strong { color: var(--ok); }
.review .evidence.weak { color: var(--warn); }
.review .evidence.none { color: var(--bad); font-weight: bold; }

@media (max-width: 560px) {
  section { padding: 18px 16px; }
  .hero-body { padding: 32px 16px 26px; }
  .ai-badge { position: static; margin-bottom: 8px; }
  .msg { max-width: 95%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* Project images */
.proj-thumb {
  display: block; margin: -16px -16px 12px; aspect-ratio: 16 / 9; overflow: hidden;
  border-radius: 16px 16px 0 0; background: var(--soft);
}
.proj-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lightbox {
  width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 48px 56px;
  border: 0; background: rgba(0, 0, 0, .9); color: #fff;
}
.lightbox[open] { display: flex; align-items: center; justify-content: center; }
.lightbox::backdrop { background: rgba(0, 0, 0, .6); }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 8px; }
.lightbox button {
  position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; padding: 0;
  border-radius: 50%; background: rgba(255, 255, 255, .15); color: #fff; font-size: 1.6rem; line-height: 1; box-shadow: none;
  direction: ltr; /* keep the arrows from being mirrored by the bidi algorithm */
}
.lightbox button:hover { background: rgba(255, 255, 255, .3); transform: translateY(-50%); box-shadow: none; }
.lightbox .lb-prev { inset-inline-start: 8px; }
.lightbox .lb-next { inset-inline-end: 8px; }
.lightbox .lb-close { top: 28px; inset-inline-end: 8px; }
.lightbox .lb-count { position: absolute; bottom: 14px; inset-inline: 0; text-align: center; font-size: .9rem; opacity: .8; }

/* Panel: gallery and passkeys */
.gallery-admin { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; margin-bottom: 16px; }
.gallery-admin figure { margin: 0; text-align: center; }
.gallery-admin img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 10px; display: block; background: var(--soft); }
button.link {
  background: none; color: var(--accent); padding: 0; box-shadow: none; font: inherit; font-weight: 500;
}
button.link:hover { transform: none; box-shadow: none; text-decoration: underline; }
button.link.danger { color: var(--bad); }
.panel-nav form { display: inline-flex; }
.panel-nav button.link { color: var(--muted); padding: 4px 12px; }
.flash.error { background: var(--bad-bg); color: var(--bad); }
.auth-box { max-width: 460px; margin: 48px auto; text-align: center; }
.auth-box h2 { justify-content: center; }
.auth-box .inline-form { justify-content: center; }
.passkey-error { color: var(--bad); margin: 12px 0 0; }
.warn-note { background: var(--warn-bg); color: var(--warn); border-radius: 12px; padding: 10px 14px; }
.setup-link { user-select: all; }
.lightbox button[hidden] { display: none; }
