/* Amer J. Abosamaha – online CV
   Plain CSS, no build step. Light theme by default, dark theme via the
   visitor's system preference or the toggle (data-theme on <html>). */

:root {
  color-scheme: light;
  --bg: #ffffff;
  --bg-elev: #f3f5f8;
  --ink: #171c26;
  --ink-2: #4a5362;
  --ink-3: #68717f;
  --accent: #164a7b;
  --accent-strong: #0f3a63;
  --accent-soft: #e6eef7;
  --rule: #d8dde5;
  --rule-strong: #b9c2cf;
  --focus: #1f6fd0;
  --selection: #cfe0f5;

  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-display: "Charter", "Bitstream Charter", "Sitka Heading", "Cambria", "Georgia", "Times New Roman", serif;

  --measure: 46rem;
  --rail: 8.75rem;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f1419;
    --bg-elev: #161d26;
    --ink: #e7eaef;
    --ink-2: #b0b8c4;
    --ink-3: #8f98a7;
    --accent: #8fbce9;
    --accent-strong: #b7d4f4;
    --accent-soft: #172637;
    --rule: #2a333f;
    --rule-strong: #3b4654;
    --focus: #8fbce9;
    --selection: #27405e;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1419;
  --bg-elev: #161d26;
  --ink: #e7eaef;
  --ink-2: #b0b8c4;
  --ink-3: #8f98a7;
  --accent: #8fbce9;
  --accent-strong: #b7d4f4;
  --accent-soft: #172637;
  --rule: #2a333f;
  --rule-strong: #3b4654;
  --focus: #8fbce9;
  --selection: #27405e;
}

/* ---------- base ---------- */

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

html {
  background: var(--bg);
  scrollbar-color: var(--rule-strong) var(--bg);
  -webkit-text-size-adjust: 100%;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.55;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--selection); color: var(--ink); }

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent);
  transition: color 150ms ease-out, text-decoration-color 150ms ease-out;
}
a:hover { color: var(--accent-strong); text-decoration-color: currentColor; }

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

h1, h2, h3 {
  margin: 0;
  font-weight: 600;
  line-height: 1.2;
  text-wrap: balance;
  overflow-wrap: anywhere;
}

p, ul, ol, dl { margin: 0; }

.skip-link {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 10;
  padding: 0.5rem 0.9rem;
  background: var(--accent);
  color: var(--bg);
  border-radius: 4px;
  text-decoration: none;
}
.skip-link:hover, .skip-link:focus { color: var(--bg); }
.skip-link:focus { top: 1rem; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.icon {
  width: 1.125rem;
  height: 1.125rem;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- layout ---------- */

.page {
  max-width: 76rem;
  margin: 0 auto;
  padding: clamp(1.25rem, 4vw, 3rem) clamp(1rem, 4vw, 2.5rem) clamp(2rem, 6vw, 4rem);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2.5rem;
}

@media (min-width: 62em) {
  .page {
    grid-template-columns: 18rem minmax(0, 1fr);
    column-gap: clamp(3rem, 6vw, 5.5rem);
    align-items: start;
  }
}

/* The sidebar follows the reader only when the whole of it fits beside the text. */
@media (min-width: 62em) and (min-height: 56em) {
  .profile {
    position: sticky;
    top: 1.5rem;
    max-height: calc(100vh - 3rem);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
  }
}

/* ---------- profile (sidebar) ---------- */

.profile {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.portrait {
  display: block;
  width: 7rem;
  height: 7rem;
}
.portrait img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-elev);
  box-shadow: 0 1px 2px rgba(10, 20, 40, 0.12), 0 6px 18px -8px rgba(10, 20, 40, 0.35);
}

.name {
  font-family: var(--font-display);
  font-size: clamp(1.85rem, 3.5vw, 2.15rem);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.1;
  color: var(--ink);
}

.role {
  color: var(--ink-2);
  font-size: 0.9rem;
  line-height: 1.45;
  max-width: 30ch;
}

.contact {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 0.3rem;
  font-size: 0.925rem;
}
.contact li {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  min-width: 0;
}
.contact .icon { position: relative; top: 0.2em; color: var(--ink-3); }
.contact a, .contact span { overflow-wrap: anywhere; }

.site-nav {
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
}
.site-nav ul {
  list-style: none;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.9rem;
  font-size: 0.925rem;
}
.site-nav a {
  display: inline-block;
  padding: 0.15rem 0;
  color: var(--ink-2);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 150ms ease-out, border-color 150ms ease-out;
}
.site-nav a:hover { color: var(--ink); border-bottom-color: var(--rule-strong); }
.site-nav a[aria-current="true"] { color: var(--accent); border-bottom-color: var(--accent); }

@media (min-width: 62em) {
  .site-nav ul { flex-direction: column; gap: 0; }
  .site-nav a { padding: 0.1rem 0; line-height: 1.35; border-bottom: 0; }
  .site-nav a:hover, .site-nav a[aria-current="true"] { border-bottom: 0; }
}

.toolbar {
  display: flex;
  gap: 0.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
}
.tool {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.75rem;
  font: inherit;
  font-size: 0.875rem;
  color: var(--ink-2);
  background: transparent;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  cursor: pointer;
  transition: color 150ms ease-out, background-color 150ms ease-out, border-color 150ms ease-out;
}
.tool:hover { color: var(--ink); background: var(--bg-elev); border-color: var(--ink-3); }
.tool .icon { width: 1rem; height: 1rem; }
.tool[hidden] { display: none; }

/* Theme button shows the icon of the theme you would switch to. */
.i-sun { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .i-sun { display: inline; }
  :root:not([data-theme="light"]) .i-moon { display: none; }
}
:root[data-theme="dark"] .i-sun { display: inline; }
:root[data-theme="dark"] .i-moon { display: none; }

/* ---------- content ---------- */

.content {
  max-width: var(--measure);
  min-width: 0;
}

section + section { margin-top: 3.25rem; }

h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.005em;
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.35rem;
}
h2::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--rule);
}

section { scroll-margin-top: 1.5rem; }

.lead {
  font-size: 1.125rem;
  line-height: 1.6;
  color: var(--ink);
  max-width: 60ch;
}

/* entries: a date rail beside the text on wide screens, stacked on narrow ones */
.entry + .entry { margin-top: 1.75rem; }
.entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.2rem 1.75rem;
}
@media (min-width: 48em) {
  .entry { grid-template-columns: var(--rail) minmax(0, 1fr); }
}

.when {
  color: var(--ink-3);
  font-size: 0.875rem;
  line-height: 1.5;
  font-variant-numeric: tabular-nums lining-nums;
  letter-spacing: 0.01em;
  white-space: nowrap;
  padding-top: 0.2rem;
}

.what { min-width: 0; }
.what h3 {
  font-size: 1.0625rem;
  line-height: 1.35;
}
.what h3 a { text-decoration-thickness: 1px; }
.where {
  color: var(--ink-2);
  font-size: 0.95rem;
  margin-top: 0.15rem;
}
.doi {
  color: var(--ink-3);
  font-size: 0.85rem;
  margin-top: 0.25rem;
  font-variant-numeric: lining-nums;
  overflow-wrap: anywhere;
}

.what ul {
  padding-left: 1.15rem;
  margin-top: 0.55rem;
  display: grid;
  gap: 0.3rem;
}
.what li::marker { color: var(--ink-3); }

.facts { margin-top: 0.6rem; display: grid; gap: 0.35rem; }
.facts div { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 0.75rem; }
.facts dt { color: var(--ink-3); font-size: 0.85rem; }
.facts dd { margin: 0; }
@media (min-width: 40em) {
  .facts div { grid-template-columns: 6.5rem minmax(0, 1fr); }
  .facts dt { font-size: inherit; }
}

.topics { display: grid; gap: 0.7rem; }
.topics div { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 1.75rem; }
.topics dt { font-weight: 600; }
.topics dd { margin: 0; color: var(--ink-2); }
@media (min-width: 48em) {
  .topics div { grid-template-columns: var(--rail) minmax(0, 1fr); }
  .topics dt { font-weight: 500; color: var(--ink); }
  #skills .topics div, #courses .topics div, #languages .topics div { grid-template-columns: 12rem minmax(0, 1fr); }
}

.group + .group { margin-top: 1.6rem; }
.group h3 {
  font-size: 1rem;
  color: var(--ink);
  margin-bottom: 0.6rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--rule);
}

.people {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 1.25rem;
}
.people h3 { font-size: 1.0625rem; }
.people p { color: var(--ink-2); font-size: 0.95rem; }
.people .where { color: var(--accent); margin-top: 0.1rem; }
.people .where + p { margin-top: 0.2rem; }
.people .reach { margin-top: 0.3rem; font-size: 0.9rem; }

.note {
  margin-top: 1.25rem;
  color: var(--ink-3);
  font-size: 0.9rem;
}

.colophon {
  margin-top: 3.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
  color: var(--ink-3);
  font-size: 0.85rem;
}

cite { font-style: italic; }

/* ---------- print ---------- */

@media print {
  :root {
    --bg: #fff;
    --bg-elev: #fff;
    --ink: #000;
    --ink-2: #222;
    --ink-3: #444;
    --accent: #000;
    --accent-strong: #000;
    --rule: #999;
    --rule-strong: #666;
  }
  @page { margin: 14mm 16mm; }

  html { scroll-behavior: auto; }
  body { font-size: 10pt; line-height: 1.38; }

  .page {
    display: block;
    max-width: none;
    padding: 0;
  }
  .profile {
    position: static;
    max-height: none;
    overflow: visible;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    column-gap: 1.2rem;
    row-gap: 0.3rem;
    align-items: start;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--rule);
  }
  .portrait { grid-row: 1 / span 3; width: 5.5rem; height: 5.5rem; }
  .portrait img { box-shadow: none; }
  .name { font-size: 1.9rem; }
  .role { max-width: none; font-size: 10pt; }
  .contact { display: flex; flex-wrap: wrap; gap: 0.3rem 1.25rem; font-size: 9.5pt; }
  .contact .icon { display: none; }
  .contact a[href^="http"]::after { content: " – " attr(href); color: var(--ink-3); }
  .site-nav, .toolbar, .skip-link { display: none !important; }

  .content { max-width: none; }
  section + section { margin-top: 1.2rem; }
  h2 { font-size: 14pt; margin-bottom: 0.6rem; break-after: avoid; }
  .lead { font-size: 10.5pt; }
  .entry, .people li, .topics div, .group { break-inside: avoid; }
  .entry + .entry { margin-top: 0.65rem; }
  .entry { grid-template-columns: 7.5rem minmax(0, 1fr); }
  .topics { gap: 0.3rem; }
  .topics div { grid-template-columns: 11rem minmax(0, 1fr); }
  .topics dt { font-weight: 500; }
  .facts div { grid-template-columns: 6.5rem minmax(0, 1fr); }
  .when { font-size: 9pt; padding-top: 0.1rem; }
  .what h3, .people h3 { font-size: 10.5pt; }
  .where, .people p { font-size: 9.5pt; }
  .people .reach { font-size: 9pt; }
  .doi { font-size: 8.5pt; }
  .what ul { margin-top: 0.25rem; gap: 0; }
  a { color: inherit; text-decoration: none; }
  .group + .group { margin-top: 0.9rem; }
  .group h3 { font-size: 10.5pt; margin-bottom: 0.3rem; }
  .people { gap: 0.6rem; }
  .colophon { margin-top: 1.5rem; padding-top: 0.6rem; font-size: 8.5pt; }
}
