/* ==========================================================================
   Ahmad Tamim Hamad — portfolio styles
   To change the colors of the whole site, edit the values in the two
   blocks below (":root" is light mode, the "dark" blocks are dark mode).
   ========================================================================== */

:root {
  --ground: #F1F4F6;       /* page background */
  --surface: #FFFFFF;      /* cards and panels */
  --ink: #16202A;          /* main text */
  --ink-soft: #36424E;     /* paragraph text */
  --muted: #55616D;        /* dates and small details */
  --line: #DCE2E7;         /* borders */
  --accent: #0B6565;       /* links and buttons */
  --accent-strong: #084A4A;
  --accent-tint: #E3F0EF;
  --on-accent: #FFFFFF;
  --outside: #A8480C;      /* the "no design can produce it" marker in the figure */
  color-scheme: light;
}

:root[data-theme="dark"] {
  --ground: #10161B;
  --surface: #182027;
  --ink: #E7ECEF;
  --ink-soft: #C6CFD6;
  --muted: #A3AFB9;
  --line: #2B3640;
  --accent: #5CC8C0;
  --accent-strong: #8ADAD4;
  --accent-tint: #17302F;
  --on-accent: #0C1418;
  --outside: #F0A45D;
  color-scheme: dark;
}

/* Follow the visitor's system setting unless they picked a mode with the button */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #10161B;
    --surface: #182027;
    --ink: #E7ECEF;
    --ink-soft: #C6CFD6;
    --muted: #A3AFB9;
    --line: #2B3640;
    --accent: #5CC8C0;
    --accent-strong: #8ADAD4;
    --accent-tint: #17302F;
    --on-accent: #0C1418;
    --outside: #F0A45D;
    color-scheme: dark;
  }
}

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 24px; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.65;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }

a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent-strong); }

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

.skip-link {
  position: absolute;
  left: 16px;
  top: -60px;
  z-index: 10;
  background: var(--accent);
  color: var(--on-accent);
  padding: 10px 16px;
  border-radius: 8px;
  text-decoration: none;
}
.skip-link:focus { top: 16px; color: var(--on-accent); }

/* ---------- Page layout: sidebar + content ---------- */

.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 32px 24px 48px;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}

main {
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-width: 0;
}

/* ---------- Sidebar ---------- */

.sidebar {
  position: sticky;
  top: 24px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 24px 24px 16px;
}

.avatar {
  position: relative;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--accent-tint);
  display: flex;
  align-items: center;
  justify-content: center;
}
.avatar-initials {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--accent);
}
.avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.name {
  margin-top: 14px;
  font-size: 26px;
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.role-line {
  margin-top: 8px;
  font-size: 14px;
  line-height: 1.45;
  font-weight: 500;
  color: var(--accent);
}
.affiliation {
  margin-top: 2px;
  font-size: 14px;
  color: var(--muted);
}
.tagline {
  margin-top: 12px;
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink-soft);
}

.site-nav {
  display: flex;
  flex-direction: column;
  margin-top: 16px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.site-nav a {
  display: block;
  padding: 5px 10px;
  margin: 0 -10px;
  line-height: 1.45;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  text-decoration: none;
}
.site-nav a:hover { background: var(--ground); color: var(--ink); }
.site-nav a.is-current { background: var(--accent-tint); color: var(--accent-strong); }

.button {
  display: block;
  margin-top: 12px;
  padding: 12px 16px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--on-accent);
  text-align: center;
  text-decoration: none;
  font-size: 15px;
  font-weight: 600;
}
.button:hover { background: var(--accent-strong); color: var(--on-accent); }

.profile-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0 14px;
  margin-top: 8px;
  font-size: 14px;
}
.profile-links a { display: inline-block; padding: 8px 0; }

.theme-toggle {
  position: absolute;
  top: 20px;
  right: 20px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
.theme-toggle:hover { color: var(--ink); border-color: var(--muted); }

/* Shorter laptop screens: tighten the sidebar so the whole menu stays visible */
@media (min-width: 941px) and (max-height: 900px) {
  .avatar { width: 64px; height: 64px; }
  .avatar-initials { font-size: 20px; }
  .name { margin-top: 12px; font-size: 24px; }
  .tagline { display: none; }
  .site-nav { margin-top: 14px; }
  .site-nav a { padding: 3px 10px; }
}

/* ---------- Panels and section headings ---------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px;
}

h2 {
  font-size: 22px;
  line-height: 1.3;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.panel > h2 { margin-bottom: 14px; }
.section-title { margin-bottom: 14px; }

h3 {
  font-size: 18px;
  line-height: 1.35;
  font-weight: 600;
}

.panel > p { max-width: 70ch; color: var(--ink-soft); }
.panel > p + p { margin-top: 12px; }

.kind {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
}
.meta { font-size: 14px; color: var(--muted); }

/* ---------- Featured research ---------- */

.feature {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 28px;
  align-items: center;
}
.feature-text h3 { margin-top: 6px; font-size: 21px; }
.feature-text p { color: var(--ink-soft); }
.feature-text h3 + p { margin-top: 10px; }
.feature-text p + p { margin-top: 10px; }
.feature-text .kind { color: var(--accent); }
.feature-text .meta { color: var(--muted); }

.reach-figure svg { display: block; width: 100%; height: auto; }
.reach-region { fill: var(--accent-tint); stroke: var(--accent); stroke-width: 2; }
.reach-inside { fill: var(--accent); }
.reach-gap { stroke: var(--outside); stroke-width: 2; stroke-dasharray: 5 5; }
.reach-outside { fill: var(--surface); stroke: var(--outside); stroke-width: 3; }

.legend {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
  font-size: 14px;
  line-height: 1.4;
  color: var(--ink-soft);
}
.legend li { display: flex; align-items: center; gap: 10px; }
.swatch { flex: 0 0 14px; width: 14px; height: 14px; border-radius: 50%; }
.swatch-region { background: var(--accent-tint); border: 2px solid var(--accent); border-radius: 4px; }
.swatch-inside { background: var(--accent); transform: scale(0.72); }
.swatch-outside { background: var(--surface); border: 3px solid var(--outside); }

/* ---------- Project cards ---------- */

.card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 16px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
}
.card h3 { margin-top: 6px; }
.card h3 + p { margin-top: 8px; font-size: 15px; line-height: 1.6; color: var(--ink-soft); }
.card-links { margin-top: auto; padding-top: 12px; font-size: 15px; font-weight: 500; }

/* ---------- Publications ---------- */

.pub + .pub { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--line); }
.pub-title { font-size: 17px; line-height: 1.4; font-weight: 600; max-width: 62ch; }
.pub-authors { margin-top: 6px; font-size: 15px; color: var(--ink-soft); }
.pub-authors strong { font-weight: 600; color: var(--ink); }
.pub-venue { margin-top: 2px; font-size: 14px; color: var(--muted); }
.pub-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.pub-links a {
  display: inline-block;
  padding: 5px 14px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
}
.pub-links a:hover { background: var(--accent-tint); }
.panel > .more { margin-top: 20px; font-size: 15px; font-weight: 500; }

/* ---------- Experience ---------- */

.role {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 4px 24px;
  padding: 18px 0;
  border-top: 1px solid var(--line);
}
h2 + .role { border-top: 0; padding-top: 4px; }
.role:last-child { padding-bottom: 0; }
.role-dates { font-size: 14px; color: var(--muted); padding-top: 3px; }
.role-org { font-size: 15px; color: var(--muted); }
.role-body ul { margin-top: 8px; padding-left: 18px; list-style: disc; max-width: 68ch; }
.role-body li { font-size: 15px; line-height: 1.6; color: var(--ink-soft); }
.role-body li + li { margin-top: 4px; }
.role-body li::marker { color: var(--accent); }

/* ---------- Skills ---------- */

.skill-group {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 8px 24px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.skill-group:first-child { border-top: 0; padding-top: 0; }
.skill-group:last-child { padding-bottom: 0; }
.skill-group dt { font-size: 15px; font-weight: 600; padding-top: 3px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tags li {
  padding: 3px 11px;
  border-radius: 999px;
  background: var(--accent-tint);
  color: var(--accent-strong);
  font-size: 14px;
  font-weight: 500;
}

/* ---------- Simple "when / what" rows (education, honors, service, contact) ---------- */

.rows li {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 2px 24px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.rows li:first-child { border-top: 0; padding-top: 0; }
.rows li:last-child { padding-bottom: 0; }
.row-when { font-size: 14px; color: var(--muted); padding-top: 2px; }
.row-what { font-size: 15px; line-height: 1.55; color: var(--ink-soft); overflow-wrap: anywhere; }
.row-what strong { font-size: 16px; font-weight: 600; color: var(--ink); }
.panel > p + .rows { margin-top: 16px; }

/* ---------- Footer ---------- */

.site-footer { padding: 4px 4px 0; font-size: 14px; color: var(--muted); }

/* ---------- Tablet and phone ---------- */

@media (max-width: 940px) {
  .page { grid-template-columns: minmax(0, 1fr); padding: 16px 16px 40px; gap: 20px; }
  .sidebar { position: relative; top: auto; max-height: none; overflow: visible; padding: 24px 20px 16px; }
  .site-nav { flex-direction: row; flex-wrap: wrap; gap: 4px 6px; padding-top: 14px; }
  .site-nav a { margin: 0; padding: 10px 12px; background: var(--ground); }
  .button { max-width: 320px; }
  .feature { grid-template-columns: minmax(0, 1fr); }
  .reach-figure { max-width: 420px; }
}

@media (max-width: 640px) {
  .panel { padding: 22px 18px; }
  .card { padding: 20px 18px; }
  .card-grid { grid-template-columns: minmax(0, 1fr); }
  .role, .skill-group, .rows li { grid-template-columns: minmax(0, 1fr); }
  .role-dates, .row-when { padding-top: 0; }
  .row-when:empty { display: none; }
}

/* ---------- Printing ---------- */

@media print {
  body { background: #FFFFFF; }
  .page { display: block; padding: 0; }
  .sidebar { position: static; max-height: none; overflow: visible; border: 0; padding: 0 0 16px; }
  .site-nav, .theme-toggle, .button, .skip-link { display: none; }
  .panel, .card { border: 0; padding: 12px 0; break-inside: avoid; }
}
