/* ============================================================
   Ali Shahroor — Academic Portfolio
   A modern, polished design with glass-morphism and animations
   ============================================================ */

:root {
  --bg: #fbfaf6;
  --bg-alt: #f2efe7;
  --surface: #ffffff;
  --glass: rgba(255, 255, 255, 0.72);
  --border: #e7e1d4;
  --text: #1b1a17;
  --text-muted: #6f6a60;
  --accent: #0f7b5a;
  --accent-soft: #dcf2e9;
  --accent-strong: #0a5b42;
  --accent2: #b45309;
  --accent2-soft: #fbebd9;
  --gradient: linear-gradient(135deg, #0f7b5a, #b45309);
  --gradient-soft: linear-gradient(135deg, #dcf2e9, #fbebd9);
  --badge-top: #0a6e50;
  --badge-top-bg: #dcf2e9;
  --badge-bg: #f2efe7;
  --badge-text: #6f6a60;
  --shadow-sm: 0 1px 2px rgba(40, 34, 20, 0.04);
  --shadow: 0 4px 6px -1px rgba(40, 34, 20, 0.06), 0 10px 15px -3px rgba(40, 34, 20, 0.08);
  --shadow-lg: 0 10px 25px -5px rgba(40, 34, 20, 0.10), 0 20px 50px -12px rgba(40, 34, 20, 0.14);
  --radius: 16px;
  --radius-sm: 10px;
  --maxw: 1100px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --mono: 'JetBrains Mono', 'Fira Code', monospace;
}

[data-theme="dark"] {
  --bg: #141410;
  --bg-alt: #1b1b14;
  --surface: #211f18;
  --glass: rgba(33, 31, 24, 0.78);
  --border: #36332a;
  --text: #ece7da;
  --text-muted: #a8a293;
  --accent: #34d8a0;
  --accent-soft: #0c3a2c;
  --accent-strong: #6fefc2;
  --accent2: #f4a340;
  --accent2-soft: #3a2a12;
  --gradient: linear-gradient(135deg, #34d8a0, #f4a340);
  --gradient-soft: linear-gradient(135deg, #0c3a2c, #3a2a12);
  --badge-top: #34d8a0;
  --badge-top-bg: #0c3a2c;
  --badge-bg: #211f18;
  --badge-text: #a8a293;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 4px 6px rgba(0, 0, 0, 0.3), 0 10px 15px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.4), 0 20px 50px rgba(0, 0, 0, 0.3);
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; }

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background 0.4s ease, color 0.4s ease;
  overflow-x: hidden;
}

/* ---- Animated Grid Background ---- */
.bg-grid {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  z-index: -1; pointer-events: none;
  background-image:
    radial-gradient(circle at 20% 50%, color-mix(in srgb, var(--accent) 6%, transparent) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, color-mix(in srgb, var(--accent2) 5%, transparent) 0%, transparent 50%),
    radial-gradient(circle at 50% 80%, color-mix(in srgb, var(--accent) 4%, transparent) 0%, transparent 40%);
}

.container { max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }
a { color: var(--accent); text-decoration: none; transition: color 0.2s ease; }
a:hover { color: var(--accent-strong); }
h1, h2, h3 { line-height: 1.25; letter-spacing: -0.025em; }
/* Serif display face for headings — gives the page its own editorial character */
.hero__text h1, .section__title, .pub-group__year, .nav__brand {
  font-family: var(--font-display);
  letter-spacing: -0.015em;
}
::selection { background: var(--accent-soft); color: var(--accent-strong); }

/* ---- Navigation ---- */
.nav {
  position: sticky; top: 0; z-index: 100;
  background: var(--glass);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--border);
  transition: background 0.4s;
}
.nav__inner { display: flex; align-items: center; justify-content: space-between; height: 68px; }
.nav__brand {
  font-weight: 900; font-size: 1.2rem; letter-spacing: 0.06em;
  color: transparent; text-decoration: none;
  background: var(--gradient); -webkit-background-clip: text; background-clip: text;
  border: 2px solid var(--accent); padding: 3px 10px; border-radius: 10px;
  transition: border-color 0.2s;
}
.nav__brand:hover { border-color: var(--accent2); text-decoration: none; }
.nav__links { display: flex; gap: 32px; }
.nav__links a {
  color: var(--text-muted); font-weight: 500; font-size: 0.95rem;
  text-decoration: none; position: relative; transition: color 0.2s;
}
.nav__links a::after {
  content: ""; position: absolute; left: 0; bottom: -6px; width: 0; height: 2.5px;
  background: var(--gradient); border-radius: 2px; transition: width 0.25s ease;
}
.nav__links a:hover, .nav__links a.active { color: var(--text); }
.nav__links a:hover::after, .nav__links a.active::after { width: 100%; }
.nav__actions { display: flex; align-items: center; gap: 12px; }

.theme-toggle {
  display: grid; place-items: center; width: 40px; height: 40px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
  color: var(--text); cursor: pointer; transition: all 0.2s;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); transform: rotate(15deg); }
.icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: block; }

.nav__burger { display: none; flex-direction: column; gap: 5px; background: none; border: none; cursor: pointer; padding: 8px; }
.nav__burger span { width: 24px; height: 2.5px; background: var(--text); border-radius: 2px; transition: 0.3s; }
.nav__burger.open span:nth-child(1) { transform: rotate(45deg) translate(5px, 5px); }
.nav__burger.open span:nth-child(2) { opacity: 0; }
.nav__burger.open span:nth-child(3) { transform: rotate(-45deg) translate(5px, -5px); }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 13px 24px; border-radius: var(--radius-sm); font-weight: 600; font-size: 0.95rem;
  text-decoration: none; cursor: pointer; border: 1px solid transparent;
  transition: all 0.2s ease;
}
.btn:hover { text-decoration: none; transform: translateY(-2px); }
.btn--primary {
  background: var(--gradient); color: #fff;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 30%, transparent);
}
.btn--primary:hover {
  box-shadow: 0 8px 25px color-mix(in srgb, var(--accent) 40%, transparent);
  color: #fff;
}
.btn--ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn--ghost:hover { border-color: var(--accent); color: var(--accent); }

/* ---- Hero Section ---- */
.hero { padding: 80px 0 64px; }
.hero__inner { display: grid; grid-template-columns: 280px 1fr; gap: 56px; align-items: center; }
.hero__photo { display: flex; flex-direction: column; align-items: center; gap: 20px; position: relative; }
.hero__photo-glow {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -55%);
  width: 280px; height: 280px; border-radius: 50%;
  background: var(--gradient); opacity: 0.15; filter: blur(40px);
  animation: pulse-glow 4s ease-in-out infinite alternate;
}
@keyframes pulse-glow {
  0% { opacity: 0.1; transform: translate(-50%, -55%) scale(0.9); }
  100% { opacity: 0.2; transform: translate(-50%, -55%) scale(1.1); }
}
.hero__photo .photo-frame {
  width: 250px; height: 250px; border-radius: 28px;
  object-fit: cover;
  object-position: 26% 22%;
  box-shadow: var(--shadow-lg); border: 4px solid var(--surface);
  position: relative; z-index: 1;
  transition: transform 0.3s ease;
  display: block;
}
.hero__photo .photo-frame:hover { transform: scale(1.03) rotate(1deg); }
.eyebrow {
  text-transform: uppercase; letter-spacing: 0.14em; font-size: 0.78rem; font-weight: 700;
  color: transparent; background: var(--gradient);
  -webkit-background-clip: text; background-clip: text;
  margin-bottom: 14px;
}
.hero__text h1 {
  font-size: clamp(2.2rem, 5vw, 3.4rem); margin-bottom: 6px;
  font-weight: 900;
}
.lead { font-size: 1.08rem; color: var(--text); max-width: 64ch; margin-bottom: 16px; }
.lead--muted { color: var(--text-muted); font-size: 1rem; }
.hero__actions { display: flex; gap: 14px; flex-wrap: wrap; margin: 28px 0 20px; }
.hero__links {
  list-style: none; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 20px;
  position: relative; z-index: 1;
}
.hero__links a {
  font-weight: 600; font-size: 0.92rem;
  padding: 6px 14px; border-radius: 8px;
  background: var(--accent-soft); transition: all 0.2s;
}
.hero__links a:hover { background: var(--accent); color: #fff; }

/* ---- Stats ---- */
.stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px;
  margin-top: 56px; padding: 32px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.stat { display: flex; flex-direction: column; gap: 6px; text-align: center; }
.stat__num {
  font-size: 1.4rem; font-weight: 800;
  color: transparent; background: var(--gradient);
  -webkit-background-clip: text; background-clip: text;
  letter-spacing: -0.02em; line-height: 1.2;
}
.stat__label { font-size: 0.83rem; color: var(--text-muted); font-weight: 500; }

/* ---- Sections ---- */
.section { padding: 80px 0; }
.section--alt { background: var(--bg-alt); }
.section__title {
  font-size: clamp(1.7rem, 3vw, 2.2rem); margin-bottom: 14px;
  position: relative; display: inline-block; font-weight: 800;
}
.section__title::after {
  content: ""; display: block; width: 56px; height: 4px; border-radius: 4px;
  background: var(--gradient); margin-top: 12px;
}
.section__intro { color: var(--text-muted); max-width: 70ch; margin-bottom: 44px; font-size: 1.05rem; }
.section__title--sub { font-size: 1.3rem; margin-top: 48px; margin-bottom: 20px; }
.section__title--sub::after { height: 3px; width: 40px; }

/* ---- Cards ---- */
.cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.cards--projects { grid-template-columns: repeat(3, 1fr); }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 28px; transition: all 0.25s ease;
  position: relative; overflow: hidden;
}
.card::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--gradient); opacity: 0; transition: opacity 0.25s;
}
.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: color-mix(in srgb, var(--accent) 30%, var(--border));
}
.card:hover::before { opacity: 1; }
.card__icon { font-size: 2rem; margin-bottom: 12px; }
.card h3 { font-size: 1.15rem; margin-bottom: 8px; font-weight: 700; }
.card p { color: var(--text-muted); font-size: 0.95rem; line-height: 1.6; }
.card--project { display: flex; flex-direction: column; }
.card--featured-project { grid-column: span 2; }
.card__tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 16px 0 14px; }
.card__tags span {
  font-size: 0.72rem; font-weight: 600; padding: 4px 12px; border-radius: 999px;
  background: var(--gradient-soft); color: var(--accent-strong);
  border: 1px solid color-mix(in srgb, var(--accent) 15%, transparent);
}
.card--project .pub__links { margin-top: auto; }

/* ---- Publications ---- */
.pub-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: -8px 0 28px;
}
.filter-btn {
  min-height: 34px;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}
.filter-btn:hover,
.filter-btn.active {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  background: var(--accent-soft);
  color: var(--accent-strong);
}
.pub-filter-empty {
  display: none;
  padding: 18px 20px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  background: var(--surface);
  font-size: 0.94rem;
}
.pub-filter-empty.show { display: block; }
.pub-group { margin-bottom: 36px; }
.pub-group.hidden { display: none; }
.pub-group__year {
  font-size: 1.6rem; font-weight: 900; margin-bottom: 20px;
  color: transparent; background: var(--gradient);
  -webkit-background-clip: text; background-clip: text;
}
.pubs { list-style: none; display: flex; flex-direction: column; gap: 20px; }
.pub {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 28px; transition: all 0.25s;
  position: relative;
}
.pub:hover {
  border-color: color-mix(in srgb, var(--accent) 30%, var(--border));
  box-shadow: var(--shadow);
}
.pub__title { font-size: 1.1rem; margin-bottom: 8px; font-weight: 700; }
.pub__authors { font-size: 0.92rem; color: var(--text-muted); margin-bottom: 8px; }
.pub__authors b { color: var(--accent-strong); font-weight: 700; }
.pub__venue { font-size: 0.92rem; color: var(--text-muted); margin-bottom: 14px; }
.pub__summary {
  color: var(--text-muted);
  font-size: 0.94rem;
  line-height: 1.65;
  margin-bottom: 14px;
}
.badge {
  display: inline-block; font-size: 0.76rem; font-weight: 700; padding: 3px 10px;
  border-radius: 6px; background: var(--badge-bg); color: var(--badge-text);
  margin-right: 8px;
}
.badge--top { background: var(--badge-top-bg); color: var(--badge-top); }
.pub__links { display: flex; flex-wrap: wrap; gap: 8px; }
.pub__links a, .pub__links button {
  font-size: 0.82rem; font-weight: 600; padding: 5px 14px; border-radius: 8px;
  background: var(--accent-soft); color: var(--accent-strong);
  text-decoration: none; border: none; cursor: pointer; font-family: inherit;
  transition: all 0.2s;
}
.pub__links a:hover, .pub__links button:hover {
  background: var(--accent); color: #fff; text-decoration: none;
}
.bibtex {
  display: none; margin-top: 14px; padding: 16px; border-radius: var(--radius-sm);
  background: var(--bg-alt); border: 1px solid var(--border);
  font-family: var(--mono); font-size: 0.8rem; line-height: 1.6;
  overflow-x: auto; white-space: pre; color: var(--text-muted);
}
.bibtex.show { display: block; animation: slideDown 0.3s ease; }

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---- Timeline ---- */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 64px; }
.timeline { list-style: none; display: flex; flex-direction: column; gap: 24px; }
.timeline__item {
  position: relative; padding-left: 24px;
  border-left: 2px solid var(--border);
}
.timeline__item::before {
  content: ""; position: absolute; left: -7px; top: 6px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--gradient); border: 2px solid var(--bg);
}
.timeline__top { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 8px; }
.timeline__role { font-weight: 700; font-size: 1rem; }
.timeline__date { font-size: 0.85rem; color: var(--accent); font-weight: 600; }
.timeline__org { font-size: 0.92rem; color: var(--text-muted); margin: 4px 0 6px; font-weight: 500; }
.timeline__desc { font-size: 0.92rem; color: var(--text-muted); line-height: 1.6; }

/* ---- Certifications & Awards ---- */
.certs, .awards { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.certs li, .awards li {
  font-size: 0.92rem; color: var(--text-muted); padding: 10px 16px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); transition: all 0.2s;
}
.certs li:hover, .awards li:hover {
  border-color: color-mix(in srgb, var(--accent) 30%, var(--border));
  transform: translateX(4px);
}
.certs li b, .awards li b { color: var(--text); }

/* ---- Language Tags ---- */
.lang-tags { display: flex; flex-wrap: wrap; gap: 10px; }
.lang-tag {
  padding: 8px 18px; border-radius: 999px; font-size: 0.9rem; font-weight: 600;
  background: var(--gradient-soft); color: var(--accent-strong);
  border: 1px solid color-mix(in srgb, var(--accent) 15%, transparent);
  transition: all 0.2s;
}
.lang-tag:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.lang-tag small { font-weight: 400; opacity: 0.7; }

/* ---- Skills ---- */
.skills-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.skill-group {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px; transition: all 0.25s;
}
.skill-group:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.skill-group h3 {
  font-size: 1rem; font-weight: 700; margin-bottom: 16px;
  color: transparent; background: var(--gradient);
  -webkit-background-clip: text; background-clip: text;
}
.skill-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.skill-tags span {
  font-size: 0.82rem; font-weight: 500; padding: 5px 14px; border-radius: 8px;
  background: var(--bg-alt); color: var(--text-muted); border: 1px solid var(--border);
  transition: all 0.2s;
}
.skill-tags span:hover { background: var(--accent-soft); color: var(--accent-strong); border-color: var(--accent); }

/* ---- Contact ---- */
.contact { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.contact__card {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 28px 20px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); text-decoration: none; color: var(--text);
  transition: all 0.25s; text-align: center;
}
.contact__card:hover {
  transform: translateY(-4px); box-shadow: var(--shadow-lg);
  border-color: var(--accent); text-decoration: none; color: var(--text);
}
.contact__icon {
  width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center;
  background: var(--gradient-soft); color: var(--accent);
  transition: all 0.25s;
}
.contact__card:hover .contact__icon { background: var(--gradient); color: #fff; }
.contact__label { font-size: 0.82rem; color: var(--text-muted); font-weight: 500; }
.contact__value { font-size: 0.88rem; font-weight: 600; color: var(--accent); word-break: break-all; }
.contact__footer { text-align: center; margin-top: 36px; color: var(--text-muted); font-size: 0.92rem; }

/* ---- Footer ---- */
.footer {
  padding: 28px 0; text-align: center; color: var(--text-muted);
  font-size: 0.88rem; border-top: 1px solid var(--border);
}

/* ---- Scroll Animations ---- */
[data-anim] {
  opacity: 0; transform: translateY(24px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
[data-anim].in-view { opacity: 1; transform: translateY(0); }

/* ---- Accessibility ---- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}
.btn:focus-visible, .nav__brand:focus-visible, .theme-toggle:focus-visible {
  outline-offset: 4px;
}

/* Respect users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  [data-anim] { opacity: 1; transform: none; }
}

/* ---- Responsive ---- */
@media (max-width: 900px) {
  .hero__inner { grid-template-columns: 1fr; text-align: center; gap: 32px; }
  .hero__text { display: flex; flex-direction: column; align-items: center; }
  .lead { text-align: center; }
  .hero__actions { justify-content: center; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .cards { grid-template-columns: 1fr; }
  .cards--projects { grid-template-columns: repeat(2, 1fr); }
  .card--featured-project { grid-column: span 2; }
  .two-col { grid-template-columns: 1fr; gap: 48px; }
  .skills-grid { grid-template-columns: 1fr; }
  .contact { grid-template-columns: repeat(2, 1fr); }
  .nav__links { display: none; }
  .nav__burger { display: flex; }
  .nav__links.open {
    display: flex; flex-direction: column; gap: 0;
    position: absolute; top: 68px; left: 0; right: 0;
    background: var(--glass); backdrop-filter: saturate(180%) blur(16px);
    -webkit-backdrop-filter: saturate(180%) blur(16px);
    border-bottom: 1px solid var(--border);
    padding: 16px 24px;
    animation: slideDown 0.3s ease;
  }
  .nav__links.open a { padding: 12px 0; border-bottom: 1px solid var(--border); }
  .nav__links.open a:last-child { border-bottom: none; }
}

@media (max-width: 640px) {
  .hero { padding: 48px 0 40px; }
  .hero__photo .photo-frame { width: 200px; height: 200px; border-radius: 24px; }
  .stats { grid-template-columns: 1fr 1fr; padding: 20px; gap: 16px; }
  .section { padding: 56px 0; }
  .cards--projects { grid-template-columns: 1fr; }
  .card--featured-project { grid-column: auto; }
  .contact { grid-template-columns: 1fr; }
  .pub { padding: 20px; }
  .hero__actions { flex-direction: column; align-items: center; }
}
