:root {
  --paper: #f6f3ee;
  --surface: #fffdf9;
  --ink: #1b1a18;
  --muted: #6b675f;
  --rule: #e2dcd1;
  --accent: #1f5f5b;
  --accent-soft: #e3ece9;
  --chip: #efe8dc;
  --shadow: 0 1px 2px rgba(60, 45, 30, 0.06), 0 6px 20px rgba(60, 45, 30, 0.06);

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --arabic: "Geeza Pro", "Noto Naskh Arabic", "Segoe UI", Tahoma, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #141413;
    --surface: #1c1b19;
    --ink: #ece8e1;
    --muted: #9b968c;
    --rule: #2e2c29;
    --accent: #7cc1b9;
    --accent-soft: #1d2a28;
    --chip: #26241f;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.25);
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration-color: var(--rule);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}

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

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

ul,
ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

h1,
h2,
h3,
p {
  margin: 0;
}

/* Layout: a sticky profile column beside the content on wide screens. */

.shell {
  max-width: 72rem;
  margin: 0 auto;
  padding: 0 1.25rem;
}

@media (min-width: 60rem) {
  .shell {
    display: grid;
    grid-template-columns: 17rem 1fr;
    gap: 4.5rem;
    padding: 0 2.5rem;
  }
}

.side {
  padding: 3rem 0 1rem;
}

@media (min-width: 60rem) {
  .side {
    position: sticky;
    top: 0;
    align-self: start;
    height: 100vh;
    padding: 5rem 0 3rem;
    display: flex;
    flex-direction: column;
  }
}

main {
  min-width: 0;
  padding: 1rem 0 3rem;
}

@media (min-width: 60rem) {
  main {
    padding: 5rem 0 4rem;
  }
}

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

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

/* Profile column */

.mark {
  display: inline-grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  margin-bottom: 1.75rem;
  border-radius: 0.7rem;
  background: var(--ink);
  color: var(--paper);
  font: 600 1.05rem/1 var(--mono);
}

h1 {
  font: 500 2.6rem/1.05 var(--serif);
  letter-spacing: -0.015em;
}

.role {
  margin-top: 0.5rem;
  color: var(--accent);
  font-weight: 600;
}

.facts {
  margin-top: 1.5rem;
  display: grid;
  gap: 0.35rem;
  font-size: 0.92rem;
}

.facts .k {
  display: inline-block;
  min-width: 4.5rem;
  color: var(--muted);
  font: 0.72rem/1.6 var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

nav {
  margin-top: 2rem;
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  scrollbar-width: none;
}

nav a {
  flex-shrink: 0;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  background: var(--chip);
  text-decoration: none;
  font-size: 0.88rem;
}

@media (min-width: 60rem) {
  nav {
    flex-direction: column;
    gap: 0.1rem;
    margin-top: 2.5rem;
  }

  nav a {
    padding: 0.3rem 0;
    background: none;
    color: var(--muted);
    font-size: 0.95rem;
  }

  nav a::before {
    content: "";
    display: inline-block;
    width: 1rem;
    height: 1px;
    margin-right: 0.75rem;
    vertical-align: middle;
    background: currentColor;
    transition: width 0.15s ease;
  }

  nav a:hover::before {
    width: 2rem;
  }
}

.social {
  margin-top: 1.5rem;
  display: flex;
  gap: 1.25rem;
  font-weight: 500;
}

@media (min-width: 60rem) {
  .social {
    margin-top: auto;
  }
}

/* Section headings */

h2 {
  margin-bottom: 1.25rem;
  color: var(--muted);
  font: 600 0.75rem/1.4 var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

h2::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--rule);
}

/* About */

.lead {
  font: 400 1.35rem/1.5 var(--serif);
  max-width: 36rem;
}

.lead strong {
  font-weight: 600;
}

.stats {
  margin-top: 2rem;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

@media (min-width: 40rem) {
  .stats {
    grid-template-columns: repeat(4, 1fr);
  }
}

.stats li {
  padding: 1rem;
  border-radius: 0.9rem;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.stats b {
  display: block;
  font: 500 2rem/1 var(--serif);
  color: var(--accent);
}

.stats span {
  display: block;
  margin-top: 0.4rem;
  font-size: 0.82rem;
  line-height: 1.35;
  color: var(--muted);
}

/* Cards */

.cards {
  display: grid;
  gap: 0.9rem;
}

@media (min-width: 40rem) {
  .cards {
    grid-template-columns: 1fr 1fr;
  }
}

.card {
  padding: 1.25rem 1.35rem;
  border-radius: 0.9rem;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.card h3 {
  margin-top: 0.5rem;
  font-size: 1.05rem;
  line-height: 1.35;
}

.card p:not(.tag) {
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.93rem;
}

.card:has(.card-link) {
  padding: 0;
  transition: transform 0.15s ease;
}

.card:has(.card-link):hover {
  transform: translateY(-2px);
}

.card-link {
  display: block;
  height: 100%;
  padding: 1.25rem 1.35rem;
  border-radius: inherit;
  text-decoration: none;
}

.card-link h3 {
  font-family: var(--mono);
  font-weight: 500;
}

.card [lang="ar"] {
  font-family: var(--arabic);
  text-align: end;
}

.tag {
  display: inline-block;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font: 600 0.7rem/1.6 var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Experience timeline */

.timeline {
  position: relative;
  display: grid;
  gap: 2.75rem;
  padding-left: 1.75rem;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 0.33rem;
  top: 0.6rem;
  bottom: 0.5rem;
  width: 2px;
  border-radius: 1px;
  background: var(--rule);
}

.job {
  position: relative;
}

.job::before {
  content: "";
  position: absolute;
  left: -1.75rem;
  top: 0.4rem;
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 50%;
  background: var(--paper);
  border: 2px solid var(--accent);
}

.job:first-child::before {
  background: var(--accent);
}

.job-head {
  display: grid;
  grid-template-columns: 1fr auto;
  column-gap: 1rem;
  align-items: baseline;
}

.job-head h3 {
  font-size: 1.1rem;
}

.job-head .org {
  grid-row: 2;
  color: var(--accent);
  font-weight: 600;
}

.job-head .when {
  grid-row: 1;
  grid-column: 2;
  color: var(--muted);
  font: 0.75rem/1.6 var(--mono);
  white-space: nowrap;
}

.ctx {
  margin-top: 0.6rem;
  color: var(--muted);
  max-width: 40rem;
}

.product {
  margin-top: 1.25rem;
}

.job ul {
  margin-top: 0.65rem;
  display: grid;
  gap: 0.45rem;
}

.job li {
  position: relative;
  padding-left: 1.1rem;
  font-size: 0.95rem;
}

.job li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.75em;
  width: 0.45rem;
  height: 2px;
  background: var(--muted);
}

.job li strong {
  font-weight: 600;
}

/* Skills */

.skills {
  display: grid;
  gap: 0.9rem;
}

@media (min-width: 40rem) {
  .skills {
    grid-template-columns: 1fr 1fr;
  }
}

.group {
  padding: 1.1rem 1.25rem 1.25rem;
  border-radius: 0.9rem;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.group h3 {
  font-size: 0.95rem;
}

.chips {
  margin-top: 0.7rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.chips li {
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: var(--chip);
  font: 0.8rem/1.5 var(--mono);
}

/* Education */

.card p.org {
  color: var(--accent);
  font-weight: 600;
}

footer {
  margin-top: 4rem;
  color: var(--muted);
  font: 0.75rem/1.4 var(--mono);
}

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

  a,
  .card,
  nav a::before {
    transition: none;
  }
}

/* Phones and tablets: a compact header, then a section menu that stays at
   the top of the screen while the page scrolls. The profile column dissolves
   (display: contents) so the menu can stick for the whole page, not only for
   the height of its own column. */

@media (max-width: 59.99rem) {
  .shell {
    display: flex;
    flex-direction: column;
  }

  .side {
    display: contents;
  }

  .mark {
    order: 1;
    align-self: flex-start;
    width: 2.25rem;
    height: 2.25rem;
    margin: 2rem 0 1rem;
    font-size: 0.9rem;
  }

  h1 {
    order: 2;
    font-size: 2.1rem;
  }

  .role {
    order: 3;
    margin-top: 0.3rem;
  }

  .facts {
    order: 4;
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem 1rem;
    margin-top: 0.9rem;
    font-size: 0.88rem;
  }

  .facts .k {
    min-width: 0;
    margin-right: 0.35rem;
  }

  .social {
    order: 5;
    margin-top: 1rem;
    gap: 0.5rem;
  }

  .social a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 1.1rem;
    border: 1px solid var(--rule);
    border-radius: 999px;
    text-decoration: none;
  }

  nav {
    order: 6;
    position: sticky;
    top: 0;
    z-index: 10;
    margin: 1.25rem -1.25rem 0;
    padding: 0.5rem 1.25rem;
    background: color-mix(in srgb, var(--paper) 90%, transparent);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--rule);
  }

  /* A fade at the right edge says the menu scrolls sideways. */
  nav::after {
    content: "";
    position: sticky;
    right: -1.25rem;
    flex: 0 0 2.5rem;
    margin-left: -2.5rem;
    background: linear-gradient(to right, transparent, var(--paper));
    pointer-events: none;
  }

  nav a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 1rem;
    font-size: 0.92rem;
  }

  nav a:last-of-type {
    margin-right: 1.5rem;
  }

  main {
    order: 7;
    padding-top: 2rem;
  }

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

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

  .lead {
    font-size: 1.2rem;
  }

  .stats {
    margin-top: 1.5rem;
    gap: 0.6rem;
  }

  .stats li {
    padding: 0.85rem;
  }

  .stats b {
    font-size: 1.75rem;
  }

  .card,
  .card-link {
    padding: 1.1rem 1.15rem;
  }

  .card:has(.card-link) {
    padding: 0;
  }

  .timeline {
    padding-left: 1.4rem;
    gap: 2.25rem;
  }

  .timeline::before {
    left: 0.3rem;
  }

  .job::before {
    left: -1.4rem;
    width: 0.75rem;
    height: 0.75rem;
  }

  /* Title, company and dates stack, so none of them has to wrap. */
  .job-head {
    grid-template-columns: 1fr;
  }

  .job-head .when {
    grid-row: 3;
    grid-column: 1;
    margin-top: 0.15rem;
  }

  .job li {
    font-size: 0.94rem;
  }

  footer {
    margin-top: 3rem;
  }
}

@media (hover: none) {
  a,
  nav a {
    -webkit-tap-highlight-color: transparent;
  }

  .card:has(.card-link):hover {
    transform: none;
  }
}
