/* ==========================================================================
   Abdelrahman Amer — personal site
   Palette & type inspired by Anthropic's warm, editorial house style.
   ========================================================================== */

:root {
  --bg:            #faf9f5;
  --bg-tint:       #f3f1e9;
  --surface:       #ffffff;
  --border:        #e5e2d6;
  --border-strong: #d6d2c2;
  --text:          #141413;
  --text-muted:    #6c6a60;
  --text-faint:    #8f8d82;
  --accent:        #c05f3c;
  --accent-soft:   #d97757;
  --accent-wash:   #f7ece6;
  --blue:          #4a7ba8;
  --green:         #64754b;

  --font-display: "Lora", Georgia, "Times New Roman", serif;
  --font-ui:      "Poppins", "Helvetica Neue", Arial, sans-serif;
  --font-body:    "Lora", Georgia, serif;

  --maxw: 1080px;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 20, 19, .04), 0 8px 24px -12px rgba(20, 20, 19, .10);

  --nav-h: 68px;
  --ease: cubic-bezier(.22, .61, .36, 1);
}

:root[data-theme="dark"] {
  --bg:            #131312;
  --bg-tint:       #1a1a18;
  --surface:       #1c1c1a;
  --border:        #2e2e2a;
  --border-strong: #3d3d37;
  --text:          #faf9f5;
  --text-muted:    #b0aea5;
  --text-faint:    #8b8981;
  --accent:        #e08a68;
  --accent-soft:   #d97757;
  --accent-wash:   #2a1f1a;
  --blue:          #7fa8d0;
  --green:         #92a375;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -12px rgba(0, 0, 0, .6);
}

/* --------------------------------------------------------------- reset -- */

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + 20px);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  /* keep the footer at the bottom of the window on short pages */
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color .3s var(--ease), color .3s var(--ease);
}

img { max-width: 100%; display: block; }
figure { margin: 0; }

a {
  color: var(--accent);
  text-decoration: none;
  transition: color .18s var(--ease);
}
a:hover { color: var(--text); }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -.015em;
  margin: 0;
  text-wrap: balance;
}

::selection { background: var(--accent-wash); color: var(--text); }

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

/* ----------------------------------------------------------- structure -- */

.wrap {
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: 28px;
}

.section { padding-block: 56px; }
.section--tint {
  background: var(--bg-tint);
  border-block: 1px solid var(--border);
}

/* section heading sits in its own left column; the card column keeps its
   original 1024px width, so the container is widened to make room for it */
.section-split {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 32px;
  align-items: start;
  max-width: 1108px;
}
/* inside the split, the card column must fill its track: auto margins would
   make this grid item shrink to its content and drift out of alignment */
.section-split .papers {
  width: 100%;
  margin-inline: 0;
}

.section-split .section-title {
  font-size: clamp(1.3rem, 1.9vw, 1.5rem);
  line-height: 1.3;
  margin-bottom: 0;
  white-space: nowrap;
}

.section-label {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 0 0 10px;
}

.section-title {
  font-size: clamp(1.7rem, 3.4vw, 2.3rem);
  margin-bottom: 8px;
}

.section-intro {
  color: var(--text-muted);
  max-width: 62ch;
  margin: 0 0 40px;
}

/* ----------------------------------------------------------------- nav -- */

.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.6) blur(12px);
  -webkit-backdrop-filter: saturate(1.6) blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color .25s var(--ease), background-color .25s var(--ease);
}
.nav.is-stuck { border-bottom-color: var(--border); }

.nav .wrap {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 20px;
}

.nav-brand {
  font-family: var(--font-display);
  font-size: 1.06rem;
  font-weight: 600;
  letter-spacing: -.01em;
  color: var(--text);
  margin-right: auto;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.nav-brand:hover { color: var(--text); }

.nav-mark {
  width: 11px;
  height: 11px;
  border-radius: 2px;
  background: var(--accent-soft);
  flex: none;
  transition: transform .35s var(--ease);
}
.nav-brand:hover .nav-mark { transform: rotate(45deg); }

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-links a {
  display: block;
  font-family: var(--font-ui);
  font-size: 14.5px;
  font-weight: 450;
  color: var(--text-muted);
  padding: 7px 13px;
  border-radius: 7px;
  transition: background-color .18s var(--ease), color .18s var(--ease);
}
.nav-links a:hover { color: var(--text); background: var(--bg-tint); }
:root[data-theme="dark"] .nav-links a:hover { background: #262624; }
.nav-links a.is-active { color: var(--text); font-weight: 550; }

.theme-toggle {
  width: 34px;
  height: 34px;
  margin-left: 6px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color .18s var(--ease), border-color .18s var(--ease), background-color .18s var(--ease);
}
.theme-toggle:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface); }
.theme-toggle svg { width: 16px; height: 16px; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun  { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

.nav-toggle { display: none; }

/* ---------------------------------------------------------------- hero -- */

.hero { padding-block: clamp(40px, 6vw, 68px) 36px; }
/* the papers section sits close under the hero so it is visible without scrolling */
.hero + .section { padding-top: 36px; }

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: clamp(32px, 6vw, 72px);
  align-items: start;
}

.hero-eyebrow {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 0 0 18px;
}

.hero h1 {
  font-size: clamp(2.5rem, 6vw, 3.9rem);
  letter-spacing: -.03em;
  margin-bottom: 22px;
}

.hero-lede {
  font-size: clamp(1.08rem, 1.6vw, 1.24rem);
  line-height: 1.6;
  color: var(--text-muted);
  max-width: 54ch;
  margin: 0 0 16px;
}
.hero-lede strong { color: var(--text); font-weight: 600; }
.hero-lede + .hero-lede { margin-top: 20px; }

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 34px;
}

.hero-portrait {
  /* sit centred against the name-to-contact block rather than the eyebrow */
  align-self: center;
  margin-top: 38px;
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.hero-portrait img {
  width: 100%;
  height: auto;              /* let aspect-ratio win over the height attribute */
  aspect-ratio: 3 / 4;
  object-fit: cover;
  object-position: 50% 22%;  /* keep the face centred when cropping */
  filter: saturate(.94);
}

/* --------------------------------------------------------------- badge -- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-family: var(--font-ui);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  background: var(--accent-wash);
  border: 1px solid color-mix(in srgb, var(--accent-soft) 30%, transparent);
  border-radius: 999px;
  padding: 6px 15px 6px 12px;
  margin-bottom: 26px;
}
.badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-soft);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-soft) 22%, transparent);
}

/* ------------------------------------------------------------- buttons -- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-family: var(--font-ui);
  font-size: 14.5px;
  font-weight: 500;
  padding: 11px 20px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform .18s var(--ease), background-color .18s var(--ease),
              border-color .18s var(--ease), color .18s var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 15px; height: 15px; flex: none; }

.btn--primary {
  background: var(--text);
  color: var(--bg);
}
.btn--primary:hover { background: var(--accent); color: #fff; }

/* read clearly as links: accent text, defined border, underline on hover */
.btn--ghost {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent) 38%, transparent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
.btn--ghost:hover {
  border-color: var(--accent);
  background: var(--accent-wash);
  color: var(--accent);
  text-decoration-color: currentColor;
}
.btn--ghost:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

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

.papers { display: grid; gap: 12px; max-width: 820px; margin-inline: auto; }

.paper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  transition: border-color .22s var(--ease), box-shadow .22s var(--ease), transform .22s var(--ease);
}
.paper:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.paper-tag {
  display: inline-block;
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-wash);
  border-radius: 5px;
  padding: 3px 9px;
  margin-bottom: 12px;
}
.paper-tag--muted {
  color: var(--text-muted);
  background: var(--bg-tint);
}

.paper h3 {
  font-size: 1.32rem;
  line-height: 1.32;
  margin-bottom: 8px;
}

.paper-authors {
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--text-muted);
  margin: 0 0 10px;
}

.paper-award {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 14.5px;
  font-style: italic;
  color: var(--green);
  margin: 0 0 14px;
}

.paper-presentations {
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--text-muted);
  margin: -6px 0 14px;
}
.paper-presentations__label {
  font-family: var(--font-ui);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-right: 0;
}

.paper-presentations__note {
  display: block;
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--text-faint);
  margin-top: 4px;
}

.paper-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 6px 12px;
  transition: color .18s var(--ease), border-color .18s var(--ease), background-color .18s var(--ease);
}
.chip:hover { color: var(--text); border-color: var(--border-strong); background: var(--bg-tint); }
.chip svg { width: 13px; height: 13px; flex: none; }
.chip--solid {
  color: var(--bg);
  background: var(--text);
  border-color: var(--text);
}
.chip--solid:hover { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ------------------------------------------------------------ abstract -- */

.abstract {
  margin-top: 18px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}
.abstract summary {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  list-style: none;
  width: fit-content;
  transition: color .18s var(--ease);
}
.abstract summary::-webkit-details-marker { display: none; }
.abstract summary:hover { color: var(--accent); }
.abstract summary::before {
  content: "";
  width: 6px;
  height: 6px;
  border-right: 1.6px solid currentColor;
  border-bottom: 1.6px solid currentColor;
  transform: rotate(-45deg);
  transition: transform .25s var(--ease);
}
.abstract[open] summary::before { transform: rotate(45deg); }
.abstract[open] summary { color: var(--text); margin-bottom: 12px; }

.abstract p {
  margin: 0;
  font-size: 15.5px;
  line-height: 1.72;
  color: var(--text-muted);
  max-width: 78ch;
}

/* -------------------------------------------------------------- course -- */

.courses {
  display: grid;
  gap: 0;
  border-top: 1px solid var(--border);
}

.course {
  display: grid;
  grid-template-columns: 108px minmax(0, 1fr) auto;
  gap: 24px;
  align-items: baseline;
  padding: 26px 4px;
  border-bottom: 1px solid var(--border);
  transition: background-color .2s var(--ease);
}
.course:hover { background: var(--bg-tint); }

.course-code {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--accent);
}

.course-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.chip--inline {
  font-size: 12px;
  line-height: 1;
  padding: 4px 10px;
}
.chip--inline svg { width: 12px; height: 12px; }

.course-note {
  font-size: 14px;
  font-style: italic;
  line-height: 1.2;
  color: var(--text-faint);
}

.course-title {
  font-family: var(--font-display);
  font-size: 1.12rem;
  font-weight: 600;
  margin: 0 0 5px;
}

.course-meta {
  font-family: var(--font-ui);
  font-size: 13.5px;
  color: var(--text-muted);
  margin: 0;
}

.course-level {
  font-family: var(--font-ui);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-faint);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 11px;
  white-space: nowrap;
}

/* ------------------------------------------------------------- contact -- */

.contact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-top: 36px;
}

.contact-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  transition: border-color .2s var(--ease), transform .2s var(--ease);
}
.contact-card:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.contact-card h3 {
  font-family: var(--font-ui);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 8px;
}
.contact-card a, .contact-card p {
  font-size: 15px;
  margin: 0;
  word-break: break-word;
}
.contact-card p { color: var(--text-muted); }

/* -------------------------------------------------------------- footer -- */

.footer {
  border-top: 1px solid var(--border);
  padding-block: 34px;
  margin-top: auto;
}
.footer .wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 28px;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-ui);
  font-size: 13.5px;
  color: var(--text-faint);
}
.footer a { color: var(--text-muted); }
.footer a:hover { color: var(--accent); }
.footer-links { display: flex; gap: 20px; flex-wrap: wrap; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

/* --------------------------------------------------------- responsive -- */

@media (max-width: 1100px) {
  .section-split { grid-template-columns: 1fr; gap: 20px; max-width: var(--maxw); }
}

@media (max-width: 860px) {
  .hero-grid { grid-template-columns: 1fr; }
  .hero-portrait { max-width: 240px; order: -1; margin-top: 0; }
  .course { grid-template-columns: 1fr; gap: 6px; }
  .course-level { justify-self: start; margin-top: 4px; }
}

@media (max-width: 620px) {
  body { font-size: 16px; }
  .wrap { padding-inline: 20px; }
  .section { padding-block: 56px; }
  .paper { padding: 22px 20px; }

  .nav-toggle {
    display: grid;
    place-items: center;
    width: 34px; height: 34px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: transparent;
    color: var(--text);
    cursor: pointer;
  }
  .nav-toggle svg { width: 17px; height: 17px; }

  .nav-links {
    position: absolute;
    top: var(--nav-h);
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding: 10px 20px 16px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
    display: none;
  }
  .nav-links.is-open { display: flex; }
  .nav-links a { padding: 11px 12px; font-size: 15.5px; }
}
