/* Base styles */
:root {
  --bg: #f8f7f4; /* subtle off white */
  --text: #1f1f1f;
  --accent: #444;
  --accent-hover: #000;
  --border: #e2e0da;
  --radius: 6px;
  --font-stack: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html {
  font-size: 16px;
  overflow-x: hidden;
}
body {
  margin: 0;
  font-family: var(--font-stack);
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  word-wrap: break-word;
  overflow-wrap: break-word;
  overflow-x: hidden;
  width: 100%;
}

::selection { background: #111; color: #fff; }

.wrapper {
  max-width: 1040px;
  margin: 0 auto;
  padding: clamp(1.5rem, 4vw, 3rem) clamp(1rem, 3vw, 2.25rem);
  width: 100%;
  box-sizing: border-box;
  min-width: 0; /* Prevents flex/grid items from overflowing */
  overflow-x: hidden;
}

header.site-header {
  display: flex;
  flex-wrap: wrap;
  gap: 2.5rem clamp(1.5rem, 5vw, 4rem);
  align-items: flex-start;
  padding-bottom: 2.2rem;
  margin-bottom: 2.8rem;
  width: 100%;
  box-sizing: border-box;
  min-width: 0;
}

/* Profile / intro columns (enhanced on wider screens) */
.profile-column { flex: 0 0 auto; display: flex; flex-direction: column; gap: 1.05rem; align-items: flex-start; min-width: 180px; }
.intro { flex: 1 1 560px; min-width: 280px; }

@media (min-width: 860px) {
  header.site-header { display: grid; grid-template-columns: 220px 1fr; gap: 3.2rem clamp(2.5rem, 5vw, 4.5rem); }
  .profile-column { position: sticky; top: 1.25rem; align-self: start; }
  .profile-column .social { flex-direction: row; width: 220px; justify-content: space-between; }
  .profile-column .social a { width: 100%; justify-content: center; }
  .bio { max-width: 900px; }
}

.profile-pic {
  width: 200px;
  height: 200px;
  border-radius: 14%; /* keep some rounding but show more rectangular context if original isn't square */
  object-fit: cover;
  border: 2px solid var(--border);
  background: #fff;
  box-shadow: 0 3px 8px -2px rgba(0,0,0,0.08);
  image-rendering: -webkit-optimize-contrast;
}

h1 { font-size: clamp(2.1rem, 4.5vw, 3.25rem); line-height: 1.1; margin: 0 0 .75rem; font-weight: 600; }

.bio { max-width: 820px; font-size: 1.08rem; line-height: 1.55; }
.bio p { margin: 0 0 1.05rem; }
.bio p:last-child { margin-bottom: 0; }

/* Microsoft Research link styling */
.microsoft-link {
  color: #0078d4; /* Microsoft blue that complements the current scheme */
  text-decoration: none;
  transition: color 0.25s ease, text-decoration 0.25s ease;
}

.microsoft-link:hover {
  color: #106ebe; /* Darker blue on hover */
  text-decoration: underline;
}

.microsoft-link:focus-visible {
  outline: 2px solid #0078d4;
  outline-offset: 2px;
}

.social {
  --icon-size: 26px;
  --hit: 44px; /* clickable area */
  display: flex;
  flex-direction: row;
  list-style: none;
  padding: 0;
  margin: .25rem; /* breathing room below photo */
}
/* Stretch icons across exact photo width with equal spacing */
.profile-column { align-items: center; }
.profile-column .social {
  width: 200px; /* matches base photo width */
  justify-content: space-between;
  gap: 0;
  padding: 0 0.5rem 0 0.4rem;
  box-sizing: border-box; /* keep total width aligned to photo */
}
.social a {
  --hover-bg: #ecebe9;
  width: var(--hit); height: var(--hit);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: #0078d4; /* Microsoft blue to match the links */
  position: relative;
  border: none;
  border-radius: 14px;
  background: transparent;
  line-height: 1;
  opacity: .85;
  transition: background .25s ease, color .25s ease, box-shadow .25s ease, transform .15s ease, opacity .25s ease;
}
.social a:hover {
  color: #106ebe; /* Darker blue on hover, matching link hover */
  opacity: 1;
  background: var(--hover-bg);
  box-shadow: 0 2px 5px rgba(0,0,0,0.06);
}
.social a:active { transform: translateY(1px) scale(.95); }
.social a:focus-visible { outline: 2px solid #0078d4; outline-offset: 3px; }
.social .icon { width: var(--icon-size); height: var(--icon-size); display: block; }
/* Remove old text spacing if any spans remain */
.social span { display: none; }

section#work { margin-top: 1rem; }
section#work h2 { font-size: 1.5rem; font-weight: 600; margin: 0 0 1.2rem; letter-spacing: .5px; }

.grid {
  --min: 260px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--min), 1fr));
  gap: 1.6rem;
  align-items: start;
}

.card {
  background: #fff;
  border: 1px solid var(--border);
  padding: .9rem .95rem 1.1rem;
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: .75rem;
  position: relative;
  overflow: hidden;
  transition: border-color .25s ease, box-shadow .25s ease;
}
.card:hover { border-color: #d0cdc5; box-shadow: 0 4px 10px -2px rgba(0,0,0,0.07); }
.card img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  border-radius: 4px;
  background: #f4f2ee;
}
.card h3 { margin: 0; font-size: 1.02rem; font-weight: 600; line-height: 1.3; }
.card p { margin: 0; font-size: .85rem; color: #555; line-height: 1.4; }

footer { margin-top: 4rem; font-size: .75rem; padding: 2.5rem 0 1.5rem; text-align: center; border-top: 1px solid var(--border); }

/* Enhanced footer styling */
.site-footer {
  margin-top: 0.5rem;
  padding: 2.5rem 0 1.5rem;
  border-top: 1px solid var(--border);
}

.footer-content {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
  text-align: center;
}

.footer-section p {
  margin: 0;
  font-size: 0.9rem;
  color: #666;
  line-height: 1.4;
}

.footer-section .microsoft-link {
  font-size: 0.9rem;
}

/* Mobile footer adjustments */
@media (max-width: 640px) {
  .site-footer {
    margin-top: 0.5rem;
    padding: 2rem 0 1rem;
  }

  .footer-content {
    gap: 0.75rem;
  }

  .footer-section p {
    font-size: 0.85rem;
  }
}

@media (max-width: 640px) {
  /* Stack vertically with tighter spacing on small screens */
  .site-header {
    flex-direction: column;
    gap: 1.75rem;
    align-items: center;
    padding-bottom: 1.8rem;
    width: 100%;
    box-sizing: border-box;
  }
  .wrapper {
    padding: 1.25rem 1rem 2rem;
    max-width: 100%;
    width: 100%;
    margin: 0;
    box-sizing: border-box;
    overflow-x: hidden;
  }
  .profile-column {
    align-items: center;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }
  .profile-pic {
    width: 160px;
    height: 160px;
  }
  /* Let the icon bar size to content instead of fixed photo width */
  .profile-column .social {
    width: auto;
    justify-content: center;
    gap: .35rem;
    flex-wrap: nowrap;
    flex-direction: row;
    box-sizing: border-box;
    max-width: 100%;
  }
  .social {
    margin: 0;
    max-width: 100%;
  }
  .social a {
    width: 44px;
    height: 44px;
  }
  h1 {
    font-size: clamp(1.8rem, 6vw, 2.2rem);
    text-align: center;
    margin: 0 0 1rem;
    word-wrap: break-word;
    hyphens: auto;
    width: 100%;
    box-sizing: border-box;
    max-width: 100%;
  }
  .intro {
    width: 100%;
    text-align: center;
    max-width: 100%;
    box-sizing: border-box;
    min-width: 0;
  }
  .bio {
    font-size: 0.95rem;
    line-height: 1.6;
    text-align: left;
    margin: 0 auto;
    max-width: 100%;
    width: 100%;
    word-wrap: break-word;
    hyphens: auto;
    box-sizing: border-box;
    overflow-wrap: break-word;
  }
  .bio p {
    margin: 0 0 1rem;
    overflow-wrap: break-word;
    width: 100%;
    box-sizing: border-box;
    max-width: 100%;
  }
}

@media (min-width: 980px) {
  .profile-pic { width: 240px; height: 240px; }
  .bio { font-size: 1.15rem; }
  /* Keep social icons horizontal on large screens */
  .profile-column .social {
    flex-direction: row;
    width: 240px;
    justify-content: space-between;
    gap: 0;
  }
}

/* Ensure medium breakpoint (640-859px) still centers profile column nicely */
@media (min-width: 641px) and (max-width: 859.98px) {
  .profile-column {
    align-items: flex-start;
    max-width: 100%;
  }
  .intro {
    min-width: 0;
    max-width: 100%;
  }
  .bio {
    max-width: 100%;
    overflow-wrap: break-word;
  }
}

/* Extra small screens (iPhone SE and smaller) */
@media (max-width: 400px) {
  .wrapper {
    padding: 1rem 0.75rem 1.5rem;
    width: 100%;
    max-width: 100%;
    margin: 0;
    box-sizing: border-box;
    overflow-x: hidden;
  }
  .profile-pic {
    width: 160px;
    height: 160px;
  }
  h1 {
    font-size: clamp(1.6rem, 7vw, 2rem);
    line-height: 1.2;
    width: 100%;
    box-sizing: border-box;
    max-width: 100%;
  }
  .bio {
    font-size: 0.9rem;
    line-height: 1.55;
    width: 100%;
    box-sizing: border-box;
    max-width: 100%;
    overflow-wrap: break-word;
  }
  .social a {
    width: 40px;
    height: 40px;
  }
  .social {
    --icon-size: 22px;
    max-width: 100%;
  }
  .intro {
    min-width: 0;
    max-width: 100%;
  }
}
