/* ============================================
   Sajjad Shahpoor — Portfolio
   ============================================ */

:root {
  --bg: #0a0e14;
  --bg-elevated: #10151f;
  --glass-bg: rgba(255, 255, 255, 0.04);
  --glass-border: rgba(255, 255, 255, 0.08);
  --text-primary: #e6f1ff;
  --text-secondary: #a8b2c1;
  --text-muted: #64748b;
  --accent: #64ffda;
  --accent-dim: rgba(100, 255, 218, 0.12);
  --accent-2: #7c9dff;
  --shadow: 0 20px 40px -20px rgba(0, 0, 0, 0.6);
  --radius: 14px;
  --max-content: 760px;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'SFMono-Regular', Consolas, monospace;
}

[data-theme="light"] {
  --bg: #f4f6fb;
  --bg-elevated: #ffffff;
  --glass-bg: rgba(10, 14, 20, 0.03);
  --glass-border: rgba(10, 14, 20, 0.08);
  --text-primary: #0f1621;
  --text-secondary: #3d4a5c;
  --text-muted: #6b7688;
  --accent: #0d9488;
  --accent-dim: rgba(13, 148, 136, 0.1);
  --accent-2: #4f5fd6;
  --shadow: 0 20px 40px -20px rgba(15, 22, 33, 0.15);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  scrollbar-color: var(--accent) transparent;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

body {
  background: var(--bg);
  color: var(--text-secondary);
  font-family: var(--font-body);
  line-height: 1.6;
  font-size: 16px;
  overflow-x: hidden;
  transition: background 0.3s ease, color 0.3s ease;
}

a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }
img { max-width: 100%; display: block; }
::selection { background: var(--accent-dim); color: var(--accent); }

/* ---------- Background canvas ---------- */
#bgCanvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  opacity: 0.5;
  pointer-events: none;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(600px circle at 15% 20%, var(--accent-dim), transparent 60%),
    radial-gradient(500px circle at 85% 70%, rgba(124, 157, 255, 0.1), transparent 60%);
  pointer-events: none;
}

/* ---------- Progress bar ---------- */
.progress-bar {
  position: fixed;
  top: 0; left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  z-index: 200;
  transition: width 0.1s ease-out;
}

/* ---------- Theme toggle ---------- */
.theme-toggle {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 150;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(12px);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: transform 0.25s ease, border-color 0.25s ease;
}
.theme-toggle:hover { transform: translateY(-2px) rotate(15deg); border-color: var(--accent); }
.theme-toggle svg { width: 20px; height: 20px; }
.theme-toggle .icon-moon { display: none; }
[data-theme="light"] .theme-toggle .icon-sun { display: none; }
[data-theme="light"] .theme-toggle .icon-moon { display: block; }

/* ---------- Mobile nav toggle ---------- */
.mobile-nav-toggle {
  display: none;
  position: fixed;
  top: 1.5rem; right: 5.5rem;
  z-index: 150;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(12px);
  cursor: pointer;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.mobile-nav-toggle span {
  width: 18px; height: 2px;
  background: var(--accent);
  border-radius: 2px;
  transition: transform 0.25s ease, opacity 0.25s ease;
}
.mobile-nav-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.mobile-nav-toggle.open span:nth-child(2) { opacity: 0; }
.mobile-nav-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---------- Layout ---------- */
.layout {
  position: relative;
  z-index: 1;
  display: flex;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 3rem;
  gap: 4rem;
}

.intro {
  position: sticky;
  top: 0;
  height: 100vh;
  width: 42%;
  max-width: 480px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.intro-content { padding: 2rem 0; }

.eyebrow {
  font-family: var(--font-mono);
  color: var(--accent);
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  margin-bottom: 1rem;
}

.intro h1 {
  font-size: clamp(2.4rem, 4.5vw, 3.4rem);
  font-weight: 800;
  line-height: 1.1;
  color: var(--text-primary);
  margin-bottom: 1.2rem;
}
.name-line { display: block; }
.gradient-text {
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.tagline {
  font-size: 1.05rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
  min-height: 1.6em;
}
.typewriter { color: var(--text-primary); font-weight: 500; }
.cursor-blink {
  color: var(--accent);
  animation: blink 1s step-end infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.location {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 2.5rem;
}
.location svg { width: 15px; height: 15px; flex-shrink: 0; }

.intro-nav ul {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  margin-bottom: 2.5rem;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 0;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.03em;
  transition: color 0.25s ease;
}
.nav-line {
  height: 1px;
  width: 24px;
  background: var(--text-muted);
  margin-right: 0.9rem;
  transition: width 0.25s ease, background 0.25s ease;
}
.nav-link:hover, .nav-link.active {
  color: var(--text-primary);
}
.nav-link:hover .nav-line, .nav-link.active .nav-line {
  width: 42px;
  background: var(--accent);
}

.intro-actions {
  display: flex;
  gap: 0.9rem;
  margin-bottom: 2.5rem;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}
.btn:hover { transform: translateY(-2px); }
.btn-primary {
  background: var(--accent);
  color: #04120f;
  font-weight: 600;
}
.btn-primary:hover { box-shadow: 0 10px 30px -10px var(--accent); }
.btn-ghost {
  background: transparent;
  color: var(--accent);
  border-color: var(--accent);
}
.btn-ghost:hover { background: var(--accent-dim); }
.btn-large { padding: 1rem 2.2rem; font-size: 0.95rem; margin-top: 0.5rem; }

.social-links {
  display: flex;
  gap: 1.4rem;
}
.social-links a {
  color: var(--text-muted);
  transition: color 0.25s ease, transform 0.25s ease;
  display: inline-flex;
}
.social-links a:hover { color: var(--accent); transform: translateY(-3px); }
.social-links svg { width: 22px; height: 22px; }

/* ---------- Content ---------- */
.content {
  width: 58%;
  padding: 2rem 0 4rem;
}

.section {
  padding: 5rem 0;
  scroll-margin-top: 2rem;
}
.section:first-child { padding-top: 8rem; }

.section-heading {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2rem;
  position: sticky;
  top: 0;
  background: transparent;
}
.section-num {
  font-family: var(--font-mono);
  color: var(--accent);
  font-size: 1.1rem;
  font-weight: 500;
}

.section-intro { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 1.5rem; }

.glass-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  backdrop-filter: blur(16px);
  transition: transform 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.section-body p { margin-bottom: 1.1rem; max-width: var(--max-content); }
.section-body.glass-card { padding: 2rem; }

/* Justify only once the column is wide enough (desktop split layout) —
   on a narrow single-column mobile view, justify stretches the few words
   per line into ugly, uneven gaps. */
@media (min-width: 1000px) {
  #about .section-body p {
    text-align: justify;
    text-justify: inter-word;
    hyphens: auto;
  }
}
.section-body strong { color: var(--text-primary); font-weight: 600; }

/* ---------- Stats ---------- */
.stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 2rem;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--glass-border);
}
.stat { display: flex; flex-direction: column; }
.stat-num, .stat-num-text {
  font-family: var(--font-mono);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--accent);
}
.stat-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* ---------- Skills ---------- */
.skills-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.2rem;
}
.skill-group { padding: 1.5rem; }
.skill-group h3 {
  font-size: 0.95rem;
  color: var(--text-primary);
  margin-bottom: 1rem;
  font-family: var(--font-mono);
}
.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.chip-list li {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid transparent;
}
.chip-list.small li { font-size: 0.72rem; padding: 0.28rem 0.6rem; }

/* ---------- Projects ---------- */
.featured-project {
  display: block;
  padding: 2rem;
  margin-bottom: 1.5rem;
  position: relative;
  overflow: hidden;
}
.featured-project::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--accent-dim), transparent 60%);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.featured-project:hover {
  transform: translateY(-4px);
  border-color: var(--accent);
  box-shadow: var(--shadow);
}
.featured-project:hover::before { opacity: 1; }
.featured-project-info { position: relative; z-index: 1; }
.featured-label {
  font-family: var(--font-mono);
  color: var(--accent);
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  margin-bottom: 0.6rem;
}
.featured-project h3 {
  font-size: 1.5rem;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
}
.featured-project p { color: var(--text-secondary); margin-bottom: 1rem; }
.featured-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1rem;
}
.pill-link {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.2rem;
  margin-bottom: 2rem;
}
.project-card {
  display: block;
  padding: 1.5rem;
}
.project-card:hover {
  transform: translateY(-4px);
  border-color: var(--accent);
  box-shadow: var(--shadow);
}
.project-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.folder-icon { width: 26px; height: 26px; color: var(--accent); }
.external-icon { color: var(--text-muted); font-size: 0.9rem; transition: transform 0.25s ease, color 0.25s ease; }
.project-card:hover .external-icon { color: var(--accent); transform: translate(2px, -2px); }
.project-card h3 { font-size: 1.05rem; color: var(--text-primary); margin-bottom: 0.5rem; }
.project-card p { font-size: 0.88rem; margin-bottom: 1rem; }

.view-all-link {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--accent);
  border-bottom: 1px solid transparent;
  transition: border-color 0.25s ease;
}
.view-all-link:hover { border-color: var(--accent); }

/* ---------- Timeline ---------- */
.timeline { position: relative; padding-left: 1.5rem; }
.timeline::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 8px;
  bottom: 8px;
  width: 1px;
  background: var(--glass-border);
}
.timeline-item { position: relative; margin-bottom: 1.5rem; }
.timeline-item:last-child { margin-bottom: 0; }
.timeline-dot {
  position: absolute;
  left: -1.5rem;
  top: 1.7rem;
  width: 11px; height: 11px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--accent);
}
.timeline-content { padding: 1.5rem; }
.timeline-org { font-weight: 700; color: var(--text-primary); font-size: 1.05rem; }
.timeline-role { color: var(--accent); font-family: var(--font-mono); font-size: 0.82rem; margin: 0.3rem 0 0.6rem; }
.timeline-desc { font-size: 0.9rem; margin-bottom: 0.6rem !important; }
.timeline-place { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 0 !important; }

/* ---------- GitHub stats ---------- */
.lang-panel {
  padding: 1.5rem;
  margin: 1.75rem 0 1.5rem;
}
.lang-panel h3 {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: var(--text-primary);
  margin-bottom: 1.1rem;
}
.lang-bar-row { margin-bottom: 0.85rem; }
.lang-bar-row:last-child { margin-bottom: 0; }
.lang-bar-label {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
}
.lang-bar-track {
  height: 6px;
  border-radius: 999px;
  background: var(--glass-border);
  overflow: hidden;
}
.lang-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}
.lang-loading { font-size: 0.85rem; color: var(--text-muted); }

/* ---------- Contact ---------- */
.section-contact { text-align: left; }
.contact-lead { max-width: 480px; font-size: 1.05rem; }

/* ---------- Footer ---------- */
.site-footer {
  padding-top: 3rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-muted);
}
.site-footer p { margin-bottom: 0.3rem; }

/* ---------- Back to top ---------- */
.back-to-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 150;
  width: 46px; height: 46px;
  border-radius: 50%;
  background: var(--accent);
  color: #04120f;
  border: none;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  box-shadow: 0 10px 30px -10px var(--accent);
}
.back-to-top.visible { opacity: 1; transform: translateY(0); pointer-events: auto; }
.back-to-top svg { width: 20px; height: 20px; }

/* ---------- Reveal animation ---------- */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}
.reveal.in-view {
  opacity: 1;
  transform: translateY(0);
}
.intro .reveal { transition-delay: calc(var(--i, 0) * 0.07s); }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .layout { flex-direction: column; padding: 0 1.5rem; gap: 0; }
  .intro {
    position: relative;
    height: auto;
    width: 100%;
    max-width: 100%;
    min-height: auto;
    align-items: flex-start;
    padding: 5.5rem 0 2rem;
  }
  .intro .intro-content { padding: 0; }
  .content { width: 100%; }
  /* 8rem clears the sticky sidebar on desktop; on stacked mobile the
     hero above it already provides breathing room. */
  .section:first-child { padding-top: 2rem; }
  .intro-nav { display: none; }
  .mobile-nav-toggle { display: flex; }

  body.nav-open .intro-nav {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 140;
    background: var(--bg);
    padding: 6rem 2rem;
  }
  body.nav-open .intro-nav ul { gap: 1.5rem; }
  body.nav-open .intro-nav .nav-link { font-size: 1.2rem; }

  .project-grid { grid-template-columns: 1fr; }
  .skills-grid { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .layout { padding: 0 1.25rem; }
  .intro h1 { font-size: 2.1rem; }
  .theme-toggle { top: 1rem; right: 1rem; }
  .mobile-nav-toggle { top: 1rem; right: 4.5rem; }
  .section { padding: 3.5rem 0; }
  .stat-row { gap: 1.4rem; }
}
