/* ---------- CSS Reset (small, mobile-friendly) ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body, h1, h2, h3, p, ul { margin: 0; }
img { max-width: 100%; height: auto; display: block; }

/* ---------- Design tokens ---------- */
:root{
  --bg: #ffffff;
  --text: #1a1a1a;
  --muted: #5e5e5e;
  --card: #f7f7f8;
  --border: #e7e7ea;
  --accent: #0d6efd;

  --radius: 16px;
  --shadow: 0 6px 24px rgba(0,0,0,.06);
  --maxw: 1100px;

  /* Fluid type for mobile → desktop */
  --step--1: clamp(0.85rem, 0.78rem + 0.3vw, 0.95rem);
  --step-0: clamp(1rem, 0.92rem + 0.6vw, 1.125rem);
  --step-1: clamp(1.25rem, 1.1rem + 1vw, 1.5rem);
  --step-2: clamp(1.5rem, 1.3rem + 1.5vw, 2rem);
  --step-3: clamp(2rem, 1.6rem + 2.5vw, 2.6rem);
}

body.dark-mode{
  --bg: #0c0d10;
  --text: #e9e9ef;
  --muted: #a1a1ad;
  --card: #14161b;
  --border: #22252c;
  --accent: #7aa2ff;
}

/* ---------- Base ---------- */
body{
  font-family: "Roboto", system-ui, -apple-system, Segoe UI, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: var(--step-0);
}

main{
  width: min(100%, var(--maxw));
  margin: 0 auto;
  padding: 16px clamp(14px, 3vw, 28px) 48px;
}

a{ color: var(--accent); text-decoration: none; }
a:hover{ text-decoration: underline; }

/* ---------- Header ---------- */
header{
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: saturate(180%) blur(10px);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  border-bottom: 1px solid var(--border);
}

header .content{
  width: min(100%, var(--maxw));
  margin: 0 auto;
  padding: 12px clamp(14px, 3vw, 28px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

h1{
  font-size: var(--step-3);
  letter-spacing: -0.02em;
  line-height: 1.1;
}

header .links{
  display: flex;
  gap: clamp(10px, 2.4vw, 18px);
}

header .links a{
  width: 44px; height: 44px; /* comfy tap targets */
  display: grid; place-items: center;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  box-shadow: var(--shadow);
}
header .links a i{ font-size: 1.2rem; }
header .links a:hover{ transform: translateY(-1px); }

/* Theme toggle */
.theme-toggle{
  position: fixed !important;
  right: max(14px, env(safe-area-inset-right)) !important;
  bottom: max(14px, env(safe-area-inset-bottom)) !important;
  top: auto !important;   /* ensure the old top:18px never applies */
  z-index: 100;
  width: 48px; height: 48px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  box-shadow: var(--shadow);
  display: grid; place-items: center;
  cursor: pointer;
}

/* ---------- Sections ---------- */
section{ margin-top: clamp(18px, 5vw, 36px); }
h2{
  margin-bottom: 12px;
  font-size: var(--step-2);
  letter-spacing: -0.01em;
}

/* About: two-column on desktop, stacked on mobile */
.about{
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: clamp(14px, 3.2vw, 22px);
  box-shadow: var(--shadow);
}
.profile-left img{
  border-radius: 12px;
  width: 160px; height: auto;
}
.profile-right p{ color: var(--text); }
.profile-right p a{ font-weight: 500; }

/* Stack on small screens */
@media (max-width: 640px){
  .about{
    grid-template-columns: 1fr;
    text-align: left;
  }
  .profile-left{
    display: flex; justify-content: center;
  }
}

/* ---------- Projects ---------- */
.projects > p{
  color: var(--muted);
  margin-bottom: 12px;
}

.project{
  display: grid;
  grid-template-columns: 1.8fr 1.2fr;
  gap: clamp(12px, 3vw, 20px);
  padding: clamp(12px, 3vw, 20px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  margin-top: 14px;
}

/* Highlighted project pops a bit more */
.project.highlight{
  outline: 2px solid color-mix(in srgb, var(--accent) 28%, transparent);
}

.project-content h3{
  font-size: var(--step-1);
  margin-bottom: 6px;
}

.project .authors{
  color: var(--muted);
  font-size: var(--step--1);
  margin-bottom: 2px;
}
.project .venue{
  color: var(--muted);
  font-size: var(--step--1);
  margin-bottom: 8px;
}
.project .venue span{
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 12%, var(--card));
  border: 1px solid var(--border);
  font-size: 0.8em;
}

.project .abstract{ color: var(--text); }
.read-more, .read-less{
  cursor: pointer;
  margin-left: 6px;
  font-weight: 500;
  color: var(--accent);
}

.project-image{
  align-self: start;
}
.project-image img{
  border-radius: 12px;
  border: 1px solid var(--border);
}

/* Links under projects */
.project .links{
  display: flex;
  gap: 10px;
  margin-top: 10px;
}
.project .links a{
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
}

/* Stack cards on phones and put image below content for readability */
@media (max-width: 860px){
  .project{
    grid-template-columns: 1fr;
  }
  .project-image{ order: 2; }
  .project-content{ order: 1; }
}

/* ---------- Services / Lists ---------- */
.services ul{ padding-left: 1.1rem; }
.services li{ margin: 6px 0; }
.services a{ word-break: break-word; }

/* ---------- Footer ---------- */
footer{
  width: min(100%, var(--maxw));
  margin: 32px auto 0;
  padding: 16px clamp(14px, 3vw, 28px) 40px;
  color: var(--muted);
  border-top: 1px solid var(--border);
  font-size: var(--step--1);
}

/* ---------- Better scroll / selection ---------- */
html{ scroll-behavior: smooth; }
::selection{ background: color-mix(in srgb, var(--accent) 32%, transparent); }
