/* =========================================================
   Mehdi Mohammadpanah — portfolio
   Theme: Deep Blue / Slate. Dark by default, light via [data-theme="light"].
   ========================================================= */

:root {
  --bg:            #070d1a;
  --bg-2:          #0b1222;
  --surface:       #0f172b;
  --surface-2:     #131d35;
  --border:        #1e2b48;
  --border-strong: #2b3c63;
  --text:          #e6edf9;
  --text-2:        #aab8d1;
  --muted:         #7387a5;
  --accent:        #5b9cf8;
  --accent-2:      #7cc4ff;
  --accent-dim:    #1b3663;
  --accent-ink:    #04101f;
  --shadow:        0 18px 44px -20px rgba(0, 0, 0, .85);
  --grid-line:     rgba(120, 160, 230, .055);
  --glow:          rgba(70, 120, 220, .28);

  --radius:    14px;
  --radius-sm: 9px;
  --maxw:      68rem;

  --sans: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", "Consolas", monospace;
}

[data-theme="light"] {
  --bg:            #eef2f9;
  --bg-2:          #f6f8fc;
  --surface:       #ffffff;
  --surface-2:     #f3f6fc;
  --border:        #d9e2f0;
  --border-strong: #b9c9e2;
  --text:          #0d1930;
  --text-2:        #3b4c6b;
  --muted:         #647693;
  --accent:        #1d4ed8;
  --accent-2:      #2563eb;
  --accent-dim:    #dbe6fb;
  --accent-ink:    #ffffff;
  --shadow:        0 16px 38px -22px rgba(23, 48, 96, .38);
  --grid-line:     rgba(30, 70, 140, .06);
  --glow:          rgba(90, 140, 230, .22);
}

*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 2.5rem;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  padding-bottom: 7rem;
  transition: background-color .3s ease, color .3s ease;
}

/* ---------- decorative background ---------- */
.bg-grid {
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 54px 54px;
  mask-image: radial-gradient(ellipse 100% 70% at 50% 0%, #000 45%, transparent 100%);
  -webkit-mask-image: radial-gradient(ellipse 100% 70% at 50% 0%, #000 45%, transparent 100%);
}

.bg-glow {
  position: fixed;
  top: -22rem;
  left: 50%;
  transform: translateX(-50%);
  width: min(74rem, 100vw);
  height: 46rem;
  z-index: -3;
  pointer-events: none;
  background: radial-gradient(closest-side, var(--glow), transparent 72%);
  filter: blur(14px);
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: var(--accent-ink);
  padding: .6rem 1rem;
  border-radius: 0 0 var(--radius-sm) 0;
  z-index: 100;
  font-weight: 600;
}
.skip-link:focus { left: 0; }

.shell {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 4.5rem 1.25rem 0;
}

/* ---------- shared icon ---------- */
.ico {
  width: 1.05em;
  height: 1.05em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ico-brand {
  fill: currentColor;
  stroke: none;
}

/* =========================================================
   HERO
   ========================================================= */
.hero {
  display: flex;
  align-items: center;
  gap: 2.5rem;
  padding-bottom: 1rem;
}
.hero-text { flex: 1 1 auto; min-width: 0; }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  margin: 0 0 1rem;
  padding: .3rem .8rem .3rem .6rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  font-family: var(--mono);
  font-size: .73rem;
  letter-spacing: .02em;
  max-width: 100%;
}
.pulse-dot {
  width: .5rem;
  height: .5rem;
  flex: none;
  border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 0 0 rgba(52, 211, 153, .6);
  animation: pulse 2.4s infinite;
}
@keyframes pulse {
  70%  { box-shadow: 0 0 0 .6rem rgba(52, 211, 153, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

.hero-name {
  margin: 0;
  /* 9vw keeps the long surname on one line right down to a 260px viewport. */
  font-size: clamp(1.4rem, 9vw, 3.6rem);
  font-weight: 800;
  overflow-wrap: break-word;
  hyphens: auto;
  line-height: 1.08;
  letter-spacing: -.035em;
}
.grad {
  background: linear-gradient(100deg, var(--accent) 5%, var(--accent-2) 60%, var(--accent) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-role {
  margin: .9rem 0 .5rem;
  color: var(--text-2);
  font-family: var(--mono);
  font-size: .88rem;
  font-weight: 500;
  letter-spacing: -.005em;
}
.hero-sub {
  margin: 0;
  max-width: 42rem;
  color: var(--muted);
  font-size: .98rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .7rem;
  margin-top: 1.7rem;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .62rem 1.15rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: .9rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: transform .18s ease, background-color .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.btn:hover { transform: translateY(-2px); }
.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 10px 26px -12px var(--accent);
}
.btn-primary:hover { background: var(--accent-2); }
.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

.hero-avatar {
  position: relative;
  flex: none;
  width: 8.5rem;
  height: 8.5rem;
  display: grid;
  place-items: center;
}
.avatar-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0 62%, var(--accent) 80%, transparent 100%);
  animation: spin 7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.avatar {
  position: relative;
  width: calc(100% - 6px);
  height: calc(100% - 6px);
  border-radius: 50%;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 2.1rem;
  font-weight: 600;
  letter-spacing: .05em;
  color: var(--accent);
}

/* The photo covers the initials when it loads; main.js removes it if it does
   not, so an empty assets/files/ still renders a tidy monogram. */
.avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  object-position: center top;
}
.avatar-initials { grid-area: 1 / 1; }

/* =========================================================
   SECTIONS
   ========================================================= */
.section { padding: 3.4rem 0 0; }

.section-title {
  display: flex;
  align-items: baseline;
  gap: .75rem;
  margin: 0 0 1.4rem;
  font-size: 1.32rem;
  font-weight: 700;
  letter-spacing: -.02em;
}
.section-title::after {
  content: "";
  flex: 1 1 auto;
  height: 1px;
  background: linear-gradient(90deg, var(--border-strong), transparent);
}
.idx {
  font-family: var(--mono);
  font-size: .78rem;
  font-weight: 500;
  color: var(--accent);
  opacity: .85;
}

.section-lead {
  margin: -.8rem 0 1.5rem;
  color: var(--muted);
  font-size: .92rem;
}

.prose {
  margin: 0;
  max-width: 54rem;
  color: var(--text-2);
  font-size: .99rem;
}
.prose strong { color: var(--text); font-weight: 600; }

/* ---------- fact row ---------- */
.fact-row {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(9rem, 100%), 1fr));
  gap: .75rem;
  margin: 1.8rem 0 0;
  padding: 0;
}
.fact-row li {
  padding: .95rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.fact-k {
  display: block;
  font-family: var(--mono);
  font-size: 1.45rem;
  font-weight: 600;
  line-height: 1.2;
  color: var(--accent);
}
.fact-k small { font-size: .55em; opacity: .8; }
.fact-v {
  display: block;
  margin-top: .15rem;
  color: var(--muted);
  font-size: .76rem;
  letter-spacing: .01em;
}

/* =========================================================
   TIMELINE / JOBS
   ========================================================= */
.timeline {
  list-style: none;
  margin: 0;
  padding: 0 0 0 1.6rem;
  position: relative;
}
.timeline::before {
  content: "";
  position: absolute;
  left: 4px;
  top: .6rem;
  bottom: 1.5rem;
  width: 2px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--accent) 0%, var(--border) 28%, var(--border) 100%);
}

.job {
  position: relative;
  padding: 0 0 2.2rem;
}
.job::before {
  content: "";
  position: absolute;
  left: -1.6rem;
  top: .55rem;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--border-strong);
  transition: border-color .2s ease, box-shadow .2s ease;
}
.job.is-current::before {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-dim);
}
.job:last-child { padding-bottom: .5rem; }

.job-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: .5rem 1.25rem;
}
.job-id { min-width: 0; }

.job-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -.015em;
}
.job-org {
  margin: .1rem 0 0;
  color: var(--accent);
  font-size: .92rem;
  font-weight: 500;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  margin-top: .55rem;
}
.chip {
  padding: .1rem .55rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: .7rem;
  letter-spacing: .015em;
}

.job-when {
  text-align: right;
  flex: none;
  padding-top: .15rem;
}
.job-range {
  display: block;
  font-family: var(--mono);
  font-size: .78rem;
  color: var(--text-2);
  white-space: nowrap;
}
.job-tenure {
  display: block;
  margin-top: .2rem;
  font-family: var(--mono);
  font-size: .72rem;
  color: var(--muted);
}
.job.is-current .job-tenure {
  color: var(--accent);
  opacity: .95;
}

.bullets {
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
}
.bullets li {
  position: relative;
  padding-left: 1.1rem;
  margin-bottom: .5rem;
  color: var(--text-2);
  font-size: .93rem;
}
.bullets li::before {
  content: "";
  position: absolute;
  left: 0;
  top: .68em;
  width: 5px;
  height: 5px;
  border-radius: 1px;
  background: var(--border-strong);
  transform: rotate(45deg);
}
.bullets strong { color: var(--text); font-weight: 600; }

/* ---------- tech tag rows ---------- */
.tech {
  display: flex;
  flex-wrap: wrap;
  gap: .32rem;
  margin-top: .9rem;
}
.tech span {
  padding: .13rem .5rem;
  border-radius: 5px;
  background: var(--accent-dim);
  color: var(--accent-2);
  font-family: var(--mono);
  font-size: .69rem;
  letter-spacing: .01em;
}
[data-theme="light"] .tech span { color: var(--accent); }

/* =========================================================
   CARDS
   ========================================================= */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(17.5rem, 100%), 1fr));
  gap: 1rem;
}
.card {
  display: flex;
  flex-direction: column;
  padding: 1.15rem 1.2rem 1.2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.card:hover {
  transform: translateY(-3px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
}
.card-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: .6rem;
}
.card-kind {
  padding: .1rem .5rem;
  border-radius: 999px;
  border: 1px solid var(--accent-dim);
  background: var(--accent-dim);
  color: var(--accent-2);
  font-family: var(--mono);
  font-size: .66rem;
  text-transform: uppercase;
  letter-spacing: .08em;
}
[data-theme="light"] .card-kind { color: var(--accent); }
.card-year {
  font-family: var(--mono);
  font-size: .7rem;
  color: var(--muted);
  white-space: nowrap;
}
.card-title {
  margin: 0 0 .45rem;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -.015em;
}
.card-body {
  margin: 0;
  flex: 1 1 auto;
  color: var(--text-2);
  font-size: .87rem;
  line-height: 1.6;
}

/* =========================================================
   SKILLS
   ========================================================= */
.skills {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(15rem, 100%), 1fr));
  gap: 1.1rem 1.6rem;
}
.skill-group h3 {
  margin: 0 0 .55rem;
  font-family: var(--mono);
  font-size: .73rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
}
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
}
.tags span {
  padding: .22rem .6rem;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text-2);
  font-size: .79rem;
  transition: border-color .18s ease, color .18s ease;
}
.tags span:hover { border-color: var(--accent); color: var(--accent); }

/* =========================================================
   EDUCATION
   ========================================================= */
.edu { list-style: none; margin: 0; padding: 0; }
.edu li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .95rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  margin-bottom: .6rem;
}
.edu h3 { margin: 0; font-size: .95rem; font-weight: 650; }
.edu p  { margin: .1rem 0 0; color: var(--muted); font-size: .85rem; }
.edu-when {
  flex: none;
  font-family: var(--mono);
  font-size: .75rem;
  color: var(--text-2);
  white-space: nowrap;
}

/* =========================================================
   CONTACT
   ========================================================= */
.contact-box {
  padding: 2rem 1.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background:
    radial-gradient(120% 140% at 50% -20%, var(--accent-dim), transparent 62%),
    var(--surface);
  text-align: center;
}
.contact-box h3 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 750;
  letter-spacing: -.025em;
}
.contact-box > p {
  margin: .5rem auto 0;
  max-width: 34rem;
  color: var(--text-2);
  font-size: .92rem;
}
.linkedin-panel {
  display: flex;
  align-items: center;
  gap: .9rem;
  width: 100%;
  max-width: 26rem;
  margin: 1.6rem auto 0;
  padding: .95rem 1.1rem;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-ink);
  text-align: left;
  text-decoration: none;
  box-shadow: 0 14px 32px -14px var(--accent);
  transition: transform .18s ease, box-shadow .18s ease, background-color .18s ease;
}
.linkedin-panel:hover {
  transform: translateY(-3px);
  background: var(--accent-2);
  box-shadow: 0 18px 38px -14px var(--accent);
}
.linkedin-mark {
  display: grid;
  place-items: center;
  flex: none;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 9px;
  background: color-mix(in srgb, var(--accent-ink) 14%, transparent);
}
.linkedin-mark .ico { width: 1.4rem; height: 1.4rem; }
.linkedin-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.35;
}
.linkedin-text strong {
  font-size: .98rem;
  font-weight: 700;
  letter-spacing: -.01em;
}
.linkedin-handle {
  font-family: var(--mono);
  font-size: .73rem;
  opacity: .82;
  /* One line always: a wrapped URL looks like a mistake. */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.linkedin-arrow {
  flex: none;
  margin-left: auto;
  width: 1.1rem;
  height: 1.1rem;
  transition: transform .18s ease;
}
.linkedin-panel:hover .linkedin-arrow { transform: translateX(3px); }

/* LinkedIn blue on hover, rather than the site accent. */
.dock-linkedin:hover { color: #0a66c2; }
[data-theme="dark"] .dock-linkedin:hover { color: #6bb5ff; }

.contact-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .55rem;
  margin-top: 1rem;
}
.contact-links a {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .5rem .9rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  color: var(--text-2);
  max-width: 100%;
  font-size: .85rem;
  text-decoration: none;
  overflow-wrap: anywhere;
  transition: color .18s ease, border-color .18s ease, transform .18s ease;
}
.contact-links a:hover {
  color: var(--accent);
  border-color: var(--accent);
  transform: translateY(-2px);
}

/* =========================================================
   FOOTER
   ========================================================= */
.foot {
  margin-top: 4rem;
  padding: 1.6rem 0 0;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--muted);
  font-size: .8rem;
}
.foot p { margin: 0 0 .3rem; }
.foot-note { font-family: var(--mono); font-size: .72rem; opacity: .75; }

/* =========================================================
   FLOATING DOCK
   ========================================================= */
.dock {
  position: fixed;
  left: 50%;
  bottom: 1.1rem;
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  align-items: center;
  gap: .18rem;
  padding: .4rem .5rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  backdrop-filter: blur(14px) saturate(160%);
  box-shadow: var(--shadow);
}
.dock a,
.dock button {
  position: relative;
  display: grid;
  place-items: center;
  width: 2.35rem;
  height: 2.35rem;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  text-decoration: none;
  font-size: 1.1rem;
  transition: background-color .18s ease, color .18s ease, transform .18s ease;
}
.dock a:hover,
.dock button:hover {
  background: var(--surface-2);
  color: var(--accent);
  transform: translateY(-3px);
}
.dock a.is-active {
  color: var(--accent);
  background: var(--accent-dim);
}
.dock .ico { width: 1.15rem; height: 1.15rem; }
.dock-sep {
  width: 1px;
  height: 1.4rem;
  margin: 0 .3rem;
  background: var(--border-strong);
}

/* sun visible in dark mode (click -> go light), moon visible in light mode */
.ico-sun  { display: block; }
.ico-moon { display: none; }
[data-theme="light"] .ico-sun  { display: none; }
[data-theme="light"] .ico-moon { display: block; }

/* =========================================================
   SCROLL REVEAL
   ========================================================= */
.reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity .55s ease, transform .55s ease;
}
.reveal.is-visible {
  opacity: 1;
  transform: none;
}
/* Never hide content if JS is unavailable. */
.no-js .reveal { opacity: 1; transform: none; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 720px) {
  .shell { padding-top: 3rem; }
  .hero {
    flex-direction: column-reverse;
    align-items: flex-start;
    gap: 1.5rem;
  }
  .hero-text { width: 100%; }
  .hero-avatar { width: 5.5rem; height: 5.5rem; }
  .avatar { font-size: 1.4rem; }
  .job-head { flex-direction: column; }
  .job-when { text-align: left; }
  .edu li { flex-direction: column; align-items: flex-start; gap: .35rem; }
  .contact-box { padding: 1.75rem 1rem; }
  .linkedin-panel { gap: .7rem; padding: .85rem .9rem; }
  .linkedin-arrow { display: none; }
  .fact-row { grid-template-columns: repeat(2, 1fr); }
  .dock { gap: 0; padding: .35rem .4rem; }
  .dock a, .dock button { width: 2.1rem; height: 2.1rem; }
}

@media (max-width: 400px) {
  .dock-sep { display: none; }
}

@media print {
  .dock, .bg-grid, .bg-glow, .hero-actions, .skip-link { display: none !important; }
  body { background: #fff; color: #000; padding-bottom: 0; }
  .reveal { opacity: 1 !important; transform: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; }
}
