/* =========================================================
   Erfan Amani Bani — Academic Homepage
   Modern academic, light theme — LBS navy on cream with red accent
   ========================================================= */

/* ---------- Tokens ---------- */
:root {
  /* Backgrounds — warm cream, layered */
  --bg-base:        #f4f0e6;
  --bg-elevated:    #faf6ec;
  --bg-soft:        #ebe5d2;
  --bg-hover:       #e0d9c1;

  /* Text — LBS navy as primary, softer blue-grey for body */
  --text-primary:   #15296e;
  --text-body:      #2d3a64;
  --text-muted:     #5e6685;
  --text-faint:     #9097ad;

  /* Accent — deeper LBS red for contrast on cream */
  --accent:         #c8102e;
  --accent-bright:  #a00b22;
  --accent-soft:    rgba(200, 16, 46, 0.09);
  --accent-line:    rgba(200, 16, 46, 0.25);

  /* Borders / rules */
  --rule:           rgba(21, 41, 110, 0.12);
  --rule-strong:    rgba(21, 41, 110, 0.20);

  /* Selection */
  --selection-bg:   rgba(200, 16, 46, 0.25);

  /* Shadows */
  --shadow-soft:    0 1px 0 rgba(21,41,110,0.04), 0 6px 20px -12px rgba(21,41,110,0.18);
  --shadow-lift:    0 10px 30px -14px rgba(21,41,110,0.22);

  /* Type */
  --font-display:   'Fraunces', 'Iowan Old Style', Georgia, serif;
  --font-body:      'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  --font-mono:      'IBM Plex Mono', 'SF Mono', Menlo, monospace;

  /* Layout */
  --radius:         4px;
  --radius-lg:      8px;
  --maxw:           1100px;
}

/* ---------- Reset / base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

html { scroll-padding-top: 90px; }

body {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 16px;
  line-height: 1.65;
  color: var(--text-body);
  background-color: var(--bg-base);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: "ss01", "ss02", "kern";
  overflow-x: hidden;
}

::selection { background: var(--selection-bg); color: var(--text-primary); }

/* Skip link — visible on keyboard focus */
.skip-link {
  position: absolute;
  top: -100px;
  left: 1rem;
  z-index: 100;
  padding: 0.55rem 0.9rem;
  background: var(--accent);
  color: var(--bg-base);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  border-radius: var(--radius);
  background-image: none;
}
.skip-link:focus { top: 0.6rem; color: var(--bg-base); }

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  line-height: 1.2;
  margin: 0;
}

a {
  color: var(--accent);
  text-decoration: none;
  background-image: linear-gradient(to right, var(--accent), var(--accent));
  background-size: 0% 1px;
  background-repeat: no-repeat;
  background-position: 0 100%;
  transition: background-size 0.3s ease, color 0.18s ease;
}

a:hover, a:focus-visible {
  background-size: 100% 1px;
  color: var(--accent-bright);
}

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

em { font-style: italic; }
strong { color: var(--text-primary); font-weight: 600; }

/* ---------- Grain texture overlay ---------- */
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.18;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.6 0'/></filter><rect width='200' height='200' filter='url(%23n)'/></svg>");
}

/* ---------- Header / nav ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background-color: color-mix(in srgb, var(--bg-base) 85%, transparent);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid var(--rule);
}

.header-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0.95rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.branding {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  background: none;
  color: inherit;
}
.branding:hover { background: none; }

.monogram {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--accent-line);
  border-radius: 50%;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  color: var(--accent);
  background: var(--accent-soft);
  transition: transform 0.4s cubic-bezier(.2,.8,.2,1);
}
.branding:hover .monogram { transform: rotate(360deg); }

.branding-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--text-primary);
  letter-spacing: -0.005em;
}
.brand-aff {
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-top: 2px;
  letter-spacing: 0.02em;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.88rem;
}

.nav-links a {
  display: inline-flex;
  align-items: baseline;
  gap: 0.4rem;
  padding: 0.45rem 0.7rem;
  border-radius: var(--radius);
  color: var(--text-muted);
  background: none;
  transition: color 0.18s ease, background-color 0.18s ease;
}

.nav-links a:hover,
.nav-links a:focus-visible {
  color: var(--text-primary);
  background-color: var(--bg-soft);
}

.nav-num {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-faint);
  letter-spacing: 0.05em;
}

.nav-links a:hover .nav-num,
.nav-links a:focus-visible .nav-num {
  color: var(--accent);
}

.nav-links .nav-primary {
  margin-left: 0.4rem;
  padding: 0.45rem 0.95rem;
  border: 1px solid var(--accent-line);
  color: var(--accent);
  background-color: var(--accent-soft);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  border-radius: var(--radius);
}

.nav-links .nav-primary:hover,
.nav-links .nav-primary:focus-visible {
  background-color: var(--accent);
  color: var(--bg-base);
  border-color: var(--accent);
}

/* ---------- Page layout ---------- */
.page { padding: 3rem 0 4rem; position: relative; z-index: 2; }

.page-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 1.5rem;
  display: grid;
  grid-template-columns: minmax(0, 300px) minmax(0, 1fr);
  gap: 3.5rem;
  align-items: start;
}

/* ---------- Sidebar / profile card ---------- */
.sidebar { position: sticky; top: 96px; }

.profile-card {
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  padding: 1.75rem 1.5rem 1.5rem;
  box-shadow: var(--shadow-soft);
  position: relative;
}

/* Decorative corner ticks — editorial flourish */
.profile-card::before,
.profile-card::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  border: 1px solid var(--accent-line);
}
.profile-card::before {
  top: -1px; left: -1px;
  border-right: 0; border-bottom: 0;
}
.profile-card::after {
  bottom: -1px; right: -1px;
  border-left: 0; border-top: 0;
}

.profile-photo-frame {
  width: 100%;
  aspect-ratio: 4 / 5;
  max-width: 240px;
  margin: 0 auto 1.25rem;
  padding: 4px;
  background: linear-gradient(135deg, var(--accent-line), transparent 60%);
  border-radius: 2px;
  box-shadow: var(--shadow-lift);
  position: relative;
}

.profile-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 2px;
  filter: grayscale(15%) contrast(1.02);
  transition: filter 0.4s ease;
}
.profile-photo-frame:hover .profile-photo { filter: grayscale(0%) contrast(1); }

.profile-name {
  font-size: 1.55rem;
  text-align: center;
  margin: 0 0 0.35rem;
  letter-spacing: -0.015em;
}

.profile-role {
  text-align: center;
  font-size: 0.88rem;
  color: var(--text-muted);
  margin: 0 0 1.1rem;
  line-height: 1.5;
}

.profile-field {
  color: var(--text-body);
  font-weight: 500;
}

.profile-inst {
  font-family: var(--font-display);
  font-style: italic;
  color: var(--accent);
  font-size: 0.92rem;
}

.profile-meta {
  border-top: 1px solid var(--rule);
  padding-top: 0.85rem;
  margin-top: 0.5rem;
}

.meta-row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.icon-mr {
  color: var(--accent);
  width: 14px;
  text-align: center;
  flex-shrink: 0;
  font-size: 0.85rem;
  margin-top: 4px;
}

.profile-links {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  margin-top: 1rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--rule);
}

.profile-links a {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.5rem 0.4rem;
  font-size: 0.85rem;
  color: var(--text-body);
  border-radius: var(--radius);
  background: none;
  transition: color 0.18s, background-color 0.18s, padding-left 0.18s;
}
.profile-links a:hover,
.profile-links a:focus-visible {
  color: var(--accent);
  background: var(--accent-soft);
  padding-left: 0.6rem;
}
.profile-links a:hover .icon-mr,
.profile-links a:focus-visible .icon-mr { color: var(--accent-bright); }

/* "Currently" note — small marginalia */
.profile-now {
  margin-top: 1rem;
  padding-top: 0.9rem;
  border-top: 1px dashed var(--rule);
  font-size: 0.78rem;
  line-height: 1.5;
}

.now-label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.3rem;
}

.now-label::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 var(--accent);
  animation: now-pulse 2.4s cubic-bezier(.4, 0, .6, 1) infinite;
  flex-shrink: 0;
}

@keyframes now-pulse {
  0% {
    box-shadow: 0 0 0 0 var(--accent-line);
  }
  70% {
    box-shadow: 0 0 0 8px transparent;
  }
  100% {
    box-shadow: 0 0 0 0 transparent;
  }
}

@media (prefers-reduced-motion: reduce) {
  .now-label::before { animation: none; }
}

.now-text {
  color: var(--text-muted);
  font-style: italic;
  font-family: var(--font-display);
}

/* ---------- Content sections ---------- */
.content { min-width: 0; }

.section {
  margin-bottom: 3.5rem;
  scroll-margin-top: 100px;
}

.section-head {
  display: flex;
  align-items: baseline;
  gap: 0.85rem;
  margin-bottom: 1.5rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--rule);
}

.section-num {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  color: var(--accent);
  position: relative;
  padding-bottom: 6px;
}

.section-num::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 2px;
  background: var(--accent);
  border-radius: 1px;
}

.section h2 {
  font-size: 1.85rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.subsection-title {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 2.25rem 0 1rem;
  display: flex;
  align-items: center;
  gap: 0.7rem;
}
.subsection-title::before,
.subsection-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--rule);
}
.subsection-title::before { flex: 0 0 18px; }

.section p {
  margin: 0 0 1rem;
  font-size: 1rem;
  color: var(--text-body);
  max-width: 62ch;
}

.section p.lede {
  font-family: var(--font-display);
  font-size: 1.18rem;
  line-height: 1.55;
  color: var(--text-primary);
  font-weight: 400;
  letter-spacing: -0.005em;
  margin-bottom: 1.2rem;
}

/* ---------- Research interests ---------- */
.research-interests {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
  padding: 1rem 1.2rem;
  background: var(--bg-elevated);
  border-left: 2px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.interest-row {
  display: flex;
  gap: 0.85rem;
  align-items: baseline;
  flex-wrap: wrap;
}

.interest-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  flex-shrink: 0;
  min-width: 110px;
}

.interest-body {
  color: var(--text-body);
  font-size: 0.96rem;
}

/* ---------- Publications ---------- */
.pub-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.pub-item {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 1.25rem;
  padding: 1.2rem 0.85rem;
  border-top: 1px solid var(--rule);
  border-left: 2px solid transparent;
  border-radius: 0 var(--radius) var(--radius) 0;
  transition:
    border-left-color 0.25s ease,
    padding-left 0.25s ease,
    background-color 0.25s ease;
}
.pub-item:first-child { border-top: 0; padding-top: 0.5rem; }
.pub-item:last-child  { border-bottom: 1px solid var(--rule); padding-bottom: 1.4rem; }

.pub-item:hover {
  border-left-color: var(--accent);
  padding-left: 1.25rem;
  background-color: var(--accent-soft);
}
.pub-item:hover .pub-year { color: var(--accent); }

.pub-year {
  font-family: var(--font-mono);
  font-size: 0.86rem;
  color: var(--text-faint);
  padding-top: 0.15rem;
  transition: color 0.2s ease;
}

.pub-body { min-width: 0; }

.pub-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.08rem;
  color: var(--text-primary);
  line-height: 1.4;
  margin-bottom: 0.4rem;
  letter-spacing: -0.005em;
}

.pub-authors {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 0.15rem;
}
.pub-authors strong { color: var(--accent); font-weight: 500; }

.pub-venue {
  font-size: 0.86rem;
  color: var(--text-muted);
}
.pub-venue em {
  color: var(--text-body);
  font-family: var(--font-display);
  font-style: italic;
}

/* ---------- Timeline (education) ---------- */
.timeline {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.timeline-item {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 1.5rem;
  padding: 0.9rem 0;
  border-top: 1px solid var(--rule);
  position: relative;
}
.timeline-item:first-child { border-top: 0; }

.timeline-date {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  padding-top: 0.15rem;
}

.timeline-title {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-primary);
}

.timeline-place {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-family: var(--font-display);
  font-style: italic;
  margin-top: 0.1rem;
}

/* ---------- Teaching ---------- */
.teaching-block {
  padding: 1rem 0;
  border-top: 1px solid var(--rule);
}
.teaching-block:first-of-type { border-top: 0; padding-top: 0.2rem; }

.teaching-role {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.6rem;
  margin-bottom: 0.4rem;
}

.teaching-place {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
}

.teaching-courses {
  font-size: 0.94rem;
  color: var(--text-body);
  margin: 0;
}

/* ---------- Experience ---------- */
.exp-block {
  padding: 1.2rem 0;
  border-top: 1px solid var(--rule);
}
.exp-block:first-of-type { border-top: 0; padding-top: 0.2rem; }

.exp-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 0.4rem;
  flex-wrap: wrap;
}

.exp-role { font-size: 1rem; }
.exp-role strong { color: var(--text-primary); }

.exp-place {
  color: var(--text-muted);
  margin-left: 0.25rem;
  font-style: italic;
  font-family: var(--font-display);
}

.exp-dates {
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.exp-text {
  margin: 0.3rem 0 0;
  font-size: 0.95rem;
  color: var(--text-body);
  max-width: 62ch;
}

/* ---------- Footer ---------- */
.site-footer {
  margin-top: 4rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--rule);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.footer-sep { color: var(--text-faint); }

/* ---------- Page-load reveal ---------- */
@media (prefers-reduced-motion: no-preference) {
  .sidebar, .section {
    opacity: 0;
    transform: translateY(8px);
    animation: reveal 0.6s cubic-bezier(.2,.7,.2,1) forwards;
  }
  .sidebar             { animation-delay: 0.05s; }
  #about               { animation-delay: 0.12s; }
  #research            { animation-delay: 0.18s; }
  #education           { animation-delay: 0.24s; }
  #teaching            { animation-delay: 0.30s; }
  #experience          { animation-delay: 0.36s; }
  #contact             { animation-delay: 0.42s; }

  @keyframes reveal {
    to { opacity: 1; transform: translateY(0); }
  }
}

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .page-inner {
    grid-template-columns: 1fr;
    gap: 2.5rem;
  }
  .sidebar {
    position: static;
    max-width: 420px;
    margin: 0 auto;
    width: 100%;
  }
}

@media (max-width: 760px) {
  .header-inner {
    padding: 0.7rem 1rem;
    flex-wrap: wrap;
    row-gap: 0.5rem;
  }
  /* Horizontal-scroll nav on mobile — keeps a single clean row */
  .nav-links {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 0.1rem;
    font-size: 0.82rem;
    padding-bottom: 2px;
  }
  .nav-links::-webkit-scrollbar { display: none; }
  .nav-links a { padding: 0.4rem 0.55rem; white-space: nowrap; flex-shrink: 0; }
  .nav-num { display: none; }
  .nav-links .nav-primary { margin-left: 0.25rem; }

  .page { padding: 2rem 0 3rem; }
  .page-inner { padding: 0 1.1rem; }

  .section { margin-bottom: 2.75rem; }
  .section h2 { font-size: 1.55rem; }
  .section p.lede { font-size: 1.05rem; }

  .pub-item {
    grid-template-columns: 1fr;
    gap: 0.4rem;
  }
  .pub-year { padding-top: 0; }

  .timeline-item {
    grid-template-columns: 1fr;
    gap: 0.2rem;
  }

  .exp-header { flex-direction: column; gap: 0.2rem; }
}

@media (max-width: 480px) {
  .header-inner { padding: 0.6rem 0.8rem; }
  .brand-name { font-size: 0.98rem; }
  .brand-aff { font-size: 0.7rem; }
  .monogram { width: 30px; height: 30px; font-size: 0.66rem; }
  .nav-links { font-size: 0.8rem; }
  .nav-links a { padding: 0.35rem 0.5rem; }
  .nav-links .nav-primary { padding: 0.35rem 0.65rem; font-size: 0.74rem; }

  .page { padding: 1.5rem 0 2.5rem; }
  .page-inner { padding: 0 1rem; }

  .profile-card { padding: 1.3rem 1.1rem 1.15rem; }
  .profile-name { font-size: 1.3rem; }
  .profile-photo-frame { max-width: 200px; }

  .section h2 { font-size: 1.4rem; }
  .section p.lede { font-size: 1rem; }
  .pub-title { font-size: 1rem; }
  .interest-row { gap: 0.4rem; }
  .interest-label { min-width: 0; }

  .research-interests { padding: 0.85rem 1rem; }
}