/* =========================================================
   Abolfazl Nezami — Developer Terminal Portfolio
   Modern interactive-terminal design system: dark, monospace,
   editor-panel aesthetic. Vanilla CSS, no framework.
   ========================================================= */

:root {
  /* Color */
  --bg: #0d1117;
  --bg-raised: #11161d;
  --panel-header: #161b22;
  --border: #30363d;
  --border-soft: rgba(139, 148, 158, 0.16);

  --text: #e6edf3;
  --text-dim: #8b949e;
  --text-faint: #5b6572;

  --accent: #58a6ff;
  --accent-dim: rgba(88, 166, 255, 0.14);
  --success: #3fb950;
  --warning: #d29922;
  --error: #f85149;

  --dot-red: #ff5f56;
  --dot-yellow: #ffbd2e;
  --dot-green: #27c93f;

  /* Type */
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'SFMono-Regular', Menlo, Consolas, monospace;
  --font-fa: 'Vazirmatn', 'Tahoma', sans-serif;

  /* Layout */
  --content-w: 980px;
  --edge: clamp(18px, 5vw, 48px);
  --radius: 10px;
  --radius-sm: 6px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 84px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  /* subtle scanline / grid texture, purely decorative */
  background-image:
    radial-gradient(circle at 15% 0%, rgba(88, 166, 255, 0.06), transparent 40%),
    radial-gradient(circle at 85% 20%, rgba(63, 185, 80, 0.05), transparent 35%);
  background-attachment: fixed;
}

html[dir="rtl"] body,
body.lang-fa {
  font-family: var(--font-fa);
}
body.lang-fa .mono,
body.lang-fa .prompt,
body.lang-fa .terminal-title,
body.lang-fa .btn,
body.lang-fa .brand-name,
body.lang-fa .hero-tagline,
body.lang-fa .nav-cmd,
body.lang-fa .term-input,
body.lang-fa .term-log,
body.lang-fa #boot-screen {
  font-family: var(--font-mono);
}
body.lang-fa .hero-headline,
body.lang-fa .about-paragraphs,
body.lang-fa .timeline-role,
body.lang-fa .timeline-bullets,
body.lang-fa .contact-text,
body.lang-fa .certificate-title,
body.lang-fa .education-degree {
  font-family: var(--font-fa);
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; margin: 0; padding: 0; }
button, input { font-family: inherit; }
button { cursor: pointer; background: none; border: none; color: inherit; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: #04101f;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  z-index: 999;
}
.skip-link:focus { left: 12px; top: 12px; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

/* ---------- boot screen ---------- */
#boot-screen {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: var(--bg);
  color: var(--success);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  padding: 24px;
  text-align: left;
  white-space: pre-wrap;
  transition: opacity 0.35s var(--ease);
}
#boot-screen.hidden { opacity: 0; pointer-events: none; }
#boot-lines .boot-line { opacity: 0; animation: boot-in 0.2s ease forwards; }
@keyframes boot-in { to { opacity: 1; } }

/* ---------- header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(13, 17, 23, 0.88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-soft);
}
.header-inner {
  max-width: var(--content-w);
  margin: 0 auto;
  padding: 14px var(--edge);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: nowrap;
  position: relative;
}
.brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.brand-logo { width: 26px; height: 26px; border-radius: 6px; }
.brand-name { font-size: 14px; color: var(--text-dim); white-space: nowrap; }
.brand-name b { color: var(--text); font-weight: 700; }

.main-nav {
  display: flex;
  gap: 2px;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  min-width: 0;
}
.main-nav::-webkit-scrollbar { display: none; }
.nav-cmd {
  white-space: nowrap;
  flex-shrink: 0;
  font-size: 13px;
  color: var(--text-dim);
  padding: 6px 9px;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
}
.nav-cmd::before { content: "$ "; color: var(--text-faint); }
.nav-cmd:hover, .nav-cmd.active { color: var(--accent); background: var(--accent-dim); }

.header-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.lang-toggle {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  color: var(--text-dim);
  display: flex;
  gap: 4px;
}
.lang-toggle:hover { border-color: var(--accent); color: var(--accent); }
.lang-toggle-en, .lang-toggle-fa { transition: color 0.15s; }
body.lang-en .lang-toggle-en { color: var(--accent); }
body.lang-fa .lang-toggle-fa { color: var(--accent); }
.lang-toggle-sep { color: var(--text-faint); }

.nav-burger { display: none; flex-direction: column; gap: 4px; width: 22px; }
.nav-burger span { display: block; height: 2px; background: var(--text-dim); border-radius: 2px; }

/* ---------- generic terminal window ---------- */
.tw {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
  overflow: hidden;
}
.tw-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--panel-header);
  border-bottom: 1px solid var(--border);
}
.tw-dots { display: flex; gap: 7px; }
.tw-dots span { width: 11px; height: 11px; border-radius: 50%; opacity: 0.85; }
.tw-dots span:nth-child(1) { background: var(--dot-red); }
.tw-dots span:nth-child(2) { background: var(--dot-yellow); }
.tw-dots span:nth-child(3) { background: var(--dot-green); }
.terminal-title { font-size: 12.5px; color: var(--text-dim); margin-inline-start: 4px; }
.tw-body { padding: 24px; }

/* ---------- hero ---------- */
.hero { padding: 48px var(--edge) 64px; }
.hero-inner { max-width: var(--content-w); margin: 0 auto; }
.hero .tw-body { padding: 28px clamp(16px, 4vw, 40px) 32px; }

.prompt { color: var(--text-dim); }
.prompt .path { color: var(--success); }
.prompt .cmd { color: var(--text); }

.hero-cmd-line { font-size: 14px; margin-bottom: 22px; }
.hero-cmd-line .cursor-static { display: inline-block; width: 8px; height: 16px; background: var(--accent); vertical-align: -3px; margin-inline-start: 2px; }

.hero-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 26px clamp(18px, 4vw, 34px);
  background: rgba(255,255,255,0.015);
}
.hero-eyebrow { color: var(--accent); font-size: 13px; font-weight: 600; letter-spacing: 0.4px; margin: 0 0 10px; }
.hero-name { font-size: clamp(30px, 5vw, 46px); font-weight: 800; margin: 0 0 6px; line-height: 1.1; }
.hero-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: var(--success);
  border: 1px solid rgba(63,185,80,0.4);
  background: rgba(63,185,80,0.08);
  border-radius: 20px;
  padding: 3px 10px;
  margin-bottom: 16px;
}
.hero-headline { color: var(--text-dim); font-size: clamp(15px, 2vw, 17px); max-width: 60ch; margin: 0 0 24px; }

.hero-cta-row { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 4px; }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  border: 1px solid var(--border);
  transition: border-color 0.18s, background 0.18s, color 0.18s, transform 0.18s;
}
.btn::before { content: "["; color: var(--text-faint); }
.btn::after { content: "]"; color: var(--text-faint); }
.btn-primary { color: var(--accent); border-color: rgba(88,166,255,0.4); background: var(--accent-dim); }
.btn-primary:hover { background: rgba(88,166,255,0.22); transform: translateY(-1px); }
.btn-ghost { color: var(--text-dim); }
.btn-ghost:hover { color: var(--text); border-color: var(--text-dim); transform: translateY(-1px); }

/* ---------- hero terminal input ---------- */
.term-shell { border-top: 1px solid var(--border-soft); margin-top: 26px; padding-top: 18px; }
.term-log { font-size: 13.5px; max-height: 220px; overflow-y: auto; margin-bottom: 6px; }
.term-log:empty { display: none; }
.term-log-line { margin-bottom: 10px; white-space: pre-wrap; }
.term-log-line .out { color: var(--text-dim); }
.term-log-line .out a { color: var(--accent); border-bottom: 1px dashed currentColor; }
.term-log-line .err { color: var(--error); }
.term-log-line .ok { color: var(--success); }
.term-input-row { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.term-input-row .path { color: var(--success); flex-shrink: 0; }
.term-input-row .sep { color: var(--text-dim); flex-shrink: 0; }
.term-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 14px;
  caret-color: var(--accent);
  min-width: 0;
}
.term-input:focus { outline: none; }
.term-hint { color: var(--text-faint); font-size: 11.5px; margin-top: 10px; }
.term-hint kbd { border: 1px solid var(--border); border-radius: 3px; padding: 1px 5px; font-size: 11px; color: var(--text-dim); }

/* ---------- sections ---------- */
.section { padding: 56px var(--edge); }
.section-inner { max-width: var(--content-w); margin: 0 auto; }
.section-title-row { display: flex; align-items: baseline; gap: 10px; margin-bottom: 20px; }
.section-title-row .prompt-mark { color: var(--success); font-size: 15px; }
.section-title { font-size: 15px; font-weight: 700; color: var(--text); letter-spacing: 0.3px; margin: 0; }
.section-kicker { color: var(--text-faint); font-size: 12.5px; margin: -14px 0 22px; }

/* about */
.about-grid { display: grid; grid-template-columns: 200px 1fr; gap: 32px; align-items: start; }
.about-media { position: relative; }
.about-image { width: 100%; aspect-ratio: 1/1; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.about-paragraphs p { color: var(--text-dim); margin: 0 0 14px; max-width: 68ch; font-size: 14px; }
.about-languages { color: var(--text-faint); font-size: 12.5px; margin-top: 10px; }
.about-languages b { color: var(--text-dim); }

/* experience timeline */
.timeline { display: flex; flex-direction: column; gap: 16px; }
.timeline-item { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 18px 20px; background: rgba(255,255,255,0.012); transition: border-color 0.2s; }
.timeline-item:hover { border-color: var(--accent); }
.timeline-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 14px; margin-bottom: 4px; }
.timeline-role { font-weight: 700; font-size: 14.5px; color: var(--text); }
.timeline-company { color: var(--accent); font-weight: 600; font-size: 13.5px; }
.timeline-period { margin-inline-start: auto; font-size: 12px; color: var(--text-faint); }
.timeline-bullets { margin: 10px 0 0; }
.timeline-bullets li { position: relative; padding-inline-start: 18px; color: var(--text-dim); font-size: 13.5px; margin-bottom: 5px; }
.timeline-bullets li::before { content: "▸"; position: absolute; inset-inline-start: 0; color: var(--success); }
.timeline-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.timeline-tags span { font-size: 10.5px; padding: 3px 9px; border: 1px solid var(--border); border-radius: 20px; color: var(--text-faint); }
.timeline-link { display: inline-block; margin-top: 10px; font-size: 12.5px; color: var(--accent); border-bottom: 1px dashed currentColor; }

/* skills */
.skills-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.skills-grid li {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-dim);
  transition: border-color 0.18s, color 0.18s, transform 0.18s;
}
.skills-grid li::before { content: "#"; color: var(--text-faint); margin-inline-end: 5px; }
.skills-grid li:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-2px); }

/* certificates */
.certificates-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.certificate-card { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px 18px; background: rgba(255,255,255,0.012); transition: border-color 0.18s; }
.certificate-card:hover { border-color: var(--accent); }
.certificate-title { font-size: 13.5px; font-weight: 700; margin: 0 0 6px; }
.certificate-title::before { content: "✓ "; color: var(--success); }
.certificate-issuer { font-size: 12px; color: var(--accent); border-bottom: 1px dashed currentColor; }

/* education */
.education-list { display: flex; flex-direction: column; gap: 14px; }
.education-item { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 18px 20px; background: rgba(255,255,255,0.012); }
.education-degree { font-size: 14.5px; font-weight: 700; margin: 0 0 4px; }
.education-school { color: var(--accent); font-size: 13.5px; margin: 0 0 4px; }
.education-period { font-size: 12px; color: var(--text-faint); margin: 0; }

/* contact */
.contact-card { text-align: left; }
.contact-text { color: var(--text-dim); font-size: 13.5px; margin: 0 0 20px; max-width: 60ch; }
.contact-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 20px; }
.contact-links { display: flex; flex-direction: column; gap: 8px; font-size: 13.5px; }
.contact-links a { color: var(--text-dim); }
.contact-links a::before { content: "→ "; color: var(--text-faint); }
.contact-links a:hover { color: var(--accent); }
.btn-sub { display: block; font-size: 10.5px; opacity: 0.75; font-weight: 500; }

/* footer */
.site-footer { border-top: 1px solid var(--border-soft); padding: 26px var(--edge) 36px; }
.footer-inner { max-width: var(--content-w); margin: 0 auto; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; font-size: 12px; color: var(--text-faint); }

/* cursor blink used inline via JS-inserted <span class="cursor"> */
.cursor { display: inline-block; width: 8px; height: 15px; background: var(--accent); vertical-align: -2px; margin-inline-start: 2px; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* section reveal on scroll */
.reveal { opacity: 0; transform: translateY(14px); transition: opacity 0.5s var(--ease), transform 0.5s var(--ease); }
.reveal.in { opacity: 1; transform: translateY(0); }

/* highlight flash when a nav/command jumps to a section */
.flash { animation: flash-border 1.1s ease; }
@keyframes flash-border {
  0% { box-shadow: 0 0 0 1px var(--accent), 0 0 24px rgba(88,166,255,0.35); }
  100% { box-shadow: none; }
}

/* reduced motion */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .cursor { animation: none; opacity: 1; }
  .reveal { opacity: 1; transform: none; transition: none; }
  #boot-lines .boot-line { animation: none; opacity: 1; }
  .flash { animation: none; }
}

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  .main-nav { display: none; }
  .nav-burger { display: flex; }
  .header-inner.open .main-nav {
    display: flex;
    position: absolute;
    top: 100%; left: 0; right: 0;
    flex-direction: column;
    background: rgba(13, 17, 23, 0.98);
    border-bottom: 1px solid var(--border);
    padding: 14px var(--edge) 20px;
    gap: 4px;
  }
  .about-grid { grid-template-columns: 1fr; }
  .about-media { max-width: 160px; }
  .certificates-grid { grid-template-columns: 1fr; }
  .timeline-period { margin-inline-start: 0; }
  .hero { padding: 32px var(--edge) 48px; }
}

@media (max-width: 480px) {
  body { font-size: 14px; }
  .section { padding: 44px var(--edge); }
  .hero .tw-body { padding: 20px 16px 24px; }
  .tw-body { padding: 18px; }
}
