/* ehtishammubarik.com
   Technical dossier. Plain HTML, no webfonts, no JavaScript in the rendering path.
   System fonts mean zero third-party requests, no font-swap layout shift, fastest LCP. */

:root {
  --bg:       #fbfbfa;
  --panel:    #f4f4f2;
  --fg:       #17171a;
  --muted:    #56565f;
  --rule:     #dcdcd8;
  --rule-hi:  #b9b9b2;
  --accent:   #8f4513;
  --accent-bg:#f3e7dd;

  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
          Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
          "Liberation Mono", monospace;

  --measure: 72ch;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:       #0c0c0e;
    --panel:    #15151a;
    --fg:       #e8e8ec;
    --muted:    #9c9ca8;
    --rule:     #27272e;
    --rule-hi:  #3d3d47;
    --accent:   #e3a568;
    --accent-bg:#2a1d12;
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;          /* anchor jumps glide; disabled below for reduced motion */
}

body {
  margin: 0;
  padding: clamp(1.75rem, 5vw, 3.5rem) clamp(1.25rem, 5vw, 2rem) 4rem;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.65;
  text-rendering: optimizeLegibility;
  /* long unbroken tokens (group_vars, matrixMulCUBLAS) wrap instead of widening
     the page on a narrow screen */
  overflow-wrap: break-word;
}

/* ---------- two column shell ---------- */
.layout {
  display: grid;
  grid-template-columns: 15rem minmax(0, var(--measure));
  gap: clamp(2rem, 5vw, 4rem);
  justify-content: center;
}

.sidebar {
  position: sticky;
  top: clamp(1.75rem, 5vw, 3.5rem);
  align-self: start;
  max-height: calc(100vh - 5rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  padding-right: 0.5rem;
}

.col { min-width: 0; }


/* headings clear the viewport edge when jumped to from the contents list */
section[id], main [id] { scroll-margin-top: 1.75rem; }
section > h2 { scroll-margin-top: 1.75rem; }

.skip {
  position: absolute; left: -9999px; top: 0;
  background: var(--fg); color: var(--bg); padding: 0.6rem 1rem; z-index: 10;
}
.skip:focus { left: 0.5rem; top: 0.5rem; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------------- masthead, inside the sidebar ---------------- */
.masthead {
  padding-bottom: 1.25rem;
  border-bottom: 3px double var(--rule-hi);
  margin-bottom: 1.5rem;
}

.portrait {
  width: 108px; height: 108px;
  display: block;
  border-radius: 3px;
  border: 1px solid var(--rule);
  object-fit: cover;
  margin-bottom: 0.9rem;
}

h1 {
  font-size: 1.4375rem;
  line-height: 1.15;
  font-weight: 640;
  letter-spacing: -0.02em;
  margin: 0 0 0.3rem;
  text-wrap: balance;
}

.role-line {
  font-family: var(--mono);
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--fg);
  margin: 0 0 0.6rem;
  letter-spacing: -0.01em;
}

.mast-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem;
  font-family: var(--mono);
  font-size: 0.8125rem;
  color: var(--muted);
  margin: 0;
}

/* ---------------- table of contents ---------------- */
.toc-head {
  font-family: var(--mono);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.6rem;
}

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

.toc a {
  display: block;
  padding: 0.3rem 0 0.3rem 0.7rem;
  border-left: 2px solid var(--rule);
  font-size: 0.875rem;
  line-height: 1.35;
  color: var(--muted);
  text-decoration: none;
}
.toc a:hover { color: var(--fg); border-left-color: var(--accent); background: var(--panel); }

.toc .n {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--accent);
  margin-right: 0.3rem;
}

.toc ul a { padding-left: 1.9rem; font-size: 0.8125rem; }

/* ---------------- burger disclosure ----------------
   Desktop: the summary is hidden and the panel is forced open, so the sidebar
   reads as an ordinary list and the <details> is invisible. Both properties are
   needed: older engines hide closed content with display, current ones use
   content-visibility on ::details-content. */
.menu > summary.burger { display: none; }
.menu > .menu-panel { display: block; }
.menu::details-content { content-visibility: visible; }

.side-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.4rem;
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
  font-size: 0.875rem;
}

.side-actions a {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none;
  border-radius: 3px;
}
.side-actions a:not(.btn) {
  color: var(--muted);
  padding: 0.3rem 0.2rem;
}
.side-actions a:not(.btn):hover { color: var(--accent); }
.side-actions .btn { justify-content: center; margin-bottom: 0.15rem; }

/* Icons scale with the type size of their link rather than a fixed px, so they
   stay proportionate at every breakpoint. Slightly under 1em keeps them at about
   cap height instead of towering over the text. */
.ico {
  width: 0.95em; height: 0.95em;
  flex: 0 0 auto;
  vertical-align: -0.12em;
}

/* A solid shape reads noticeably heavier than a stroked one at the same box size,
   so the brand marks are stepped down to match the optical weight of the rest. */
.ico:has(use[href="#i-github"]),
.ico:has(use[href="#i-linkedin"]) { width: 0.85em; height: 0.85em; }

/* In a row of links the label carries the meaning; the icon is a marker, so it
   recedes rather than competing in the accent colour. */
.actions a:not(.btn) .ico { color: var(--muted); }
.actions a:not(.btn):hover .ico { color: var(--accent); }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.badge {
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-bg);
  border: 1px solid var(--accent);
  border-radius: 2px;
  padding: 0.15rem 0.45rem;
  white-space: nowrap;
}

/* ---------------- sections ---------------- */
section { margin-bottom: 3.25rem; }

h2 {
  display: flex; align-items: baseline; gap: 0.7rem;
  font-size: 0.9375rem;
  font-family: var(--mono);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg);
  margin: 0 0 1.35rem;
  padding-bottom: 0.55rem;
  border-bottom: 1px solid var(--rule-hi);
}

.idx {
  font-size: 0.8125rem;
  color: var(--accent);
  letter-spacing: 0.02em;
  flex: 0 0 auto;
}

h3 {
  font-size: 1.0625rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  margin: 2rem 0 0.45rem;
}

.stage {
  display: block;
  font-family: var(--mono);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.2rem;
}

p { margin: 0 0 1.05rem; }

.lede {
  font-size: clamp(1.125rem, 2.9vw, 1.3125rem);
  line-height: 1.42;
  font-weight: 480;
  letter-spacing: -0.015em;
  margin-bottom: 1.2rem;
  text-wrap: pretty;
}

.pull {
  border-left: 2px solid var(--accent);
  background: var(--panel);
  padding: 0.85rem 1.1rem;
  margin: 1.5rem 0;
  font-size: 1rem;
}

.note {
  color: var(--muted);
  font-size: 0.9375rem;
  border-left: 2px solid var(--rule);
  padding-left: 1rem;
  margin-bottom: 1.75rem;
}

.meta-line, .dates {
  font-family: var(--mono);
  font-size: 0.8125rem;
  color: var(--muted);
  margin: 0 0 0.5rem;
}

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }

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

em { font-style: italic; }

/* ---------------- actions ---------------- */
.actions {
  display: flex; flex-wrap: wrap; gap: 0.6rem 1.25rem; align-items: center;
  font-size: 0.9375rem; margin: 1.5rem 0 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--mono);
  font-size: 0.8125rem;
  letter-spacing: 0.02em;
  text-decoration: none;
  color: var(--bg);
  background: var(--fg);
  border: 1px solid var(--fg);
  padding: 0.55rem 0.9rem;
  border-radius: 3px;
}
.btn:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { .btn:hover { color: #0c0c0e; } }

/* Secondary button. Two solid buttons side by side compete for the same
   attention, so the thesis is outlined and the resume stays solid. */
.btn.ghost {
  background: transparent;
  color: var(--fg);
  border-color: var(--rule-hi);
}
.btn.ghost:hover { background: transparent; border-color: var(--accent); color: var(--accent); }
@media (prefers-color-scheme: dark) { .btn.ghost:hover { color: var(--accent); } }

/* Section action rows keep icons aligned with their labels. */
.actions a { display: inline-flex; align-items: center; gap: 0.5rem; }

/* ---------------- tables ---------------- */
.scroll-x { overflow-x: auto; margin: 0 0 1.25rem; }

table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }

caption {
  caption-side: top; text-align: left;
  font-family: var(--mono); font-size: 0.75rem;
  letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--muted); padding-bottom: 0.6rem;
}

thead th {
  font-family: var(--mono);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: left;
  padding: 0.45rem 0.85rem 0.45rem 0;
  border-bottom: 1px solid var(--rule-hi);
  white-space: nowrap;
}

tbody td {
  text-align: left;
  padding: 0.55rem 0.85rem 0.55rem 0;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}

tbody td:not(:first-child) { font-family: var(--mono); font-size: 0.875rem; }

.ev td:first-child { max-width: 30ch; }
.num { color: var(--accent); font-weight: 600; white-space: nowrap; }

/* ---------------- definition lists ---------------- */
dl { margin: 0; }

dt {
  font-family: var(--mono);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--fg);
  margin-top: 1.5rem;
}
dt:first-of-type { margin-top: 0; }

dd { margin: 0.3rem 0 0; color: var(--muted); }
.creds dd { color: var(--fg); }

/* ---------------- roles ---------------- */
.role {
  margin-bottom: 2rem;
  padding-bottom: 1.75rem;
  border-bottom: 1px solid var(--rule);
}
.role:last-child { border-bottom: 0; padding-bottom: 0; }

.role h3 { margin: 0 0 0.5rem; }

.role h3 .meta {
  display: block;
  font-family: var(--mono);
  font-size: 0.8125rem;
  font-weight: 400;
  color: var(--muted);
  letter-spacing: 0;
  margin-top: 0.15rem;
}

.role p:last-child { margin-bottom: 0; }

/* ---------------- footer ---------------- */
footer {
  margin-top: 3.5rem;
  padding-top: 1.5rem;
  border-top: 3px double var(--rule-hi);
  font-size: 0.875rem;
  color: var(--muted);
}
footer p { margin: 0 0 0.3rem; }
.updated { font-family: var(--mono); font-size: 0.8125rem; }

/* the section you jumped to gets a brief marker, no JS needed */
section:target > h2,
dt:target {
  border-left: 2px solid var(--accent);
  padding-left: 0.6rem;
  margin-left: -0.8rem;
}

/* ---------------- phones ---------------- */
/* single column before the sidebar starts squeezing the prose */
@media (max-width: 62rem) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
    max-width: var(--measure);
    margin-inline: auto;
    gap: 2rem;
  }

  .sidebar {
    position: relative;               /* anchors the burger and its dropdown */
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }

  /* ---- the masthead becomes a header bar with a burger on the right ---- */
  .masthead { position: relative; margin-bottom: 0; }

  /* Only the name shares a line with the burger, so only the name needs the
     clearance. Reserving it on the whole masthead squeezed the meta row and
     pushed the badge onto a line of its own. */
  .masthead h1 { padding-right: 3.25rem; }

  /* The whole disclosure is a small control parked in the top right corner. It
     takes no layout space, so nothing shifts when it opens. */
  .menu {
    position: absolute;
    top: -0.2rem;
    right: -0.35rem;
    z-index: 30;
  }

  .menu > summary.burger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: 0;                        /* no box: the icon alone is the control */
    color: var(--muted);
    cursor: pointer;
    list-style: none;                 /* kill the default disclosure triangle */
  }
  .menu > summary.burger::-webkit-details-marker { display: none; }
  .menu > summary.burger::marker { content: ""; }
  .menu > summary.burger:hover { color: var(--accent); }

  .burger .ico { width: 1.15rem; height: 1.15rem; }
  .burger-label {
    position: absolute; width: 1px; height: 1px; margin: -1px;
    padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
  }
  .menu:not([open]) .burger-shut { display: none; }
  .menu[open] .burger-open { display: none; }
  .menu[open] > summary.burger { color: var(--fg); }

  /* A dropdown that floats over the page rather than a full width slab that
     pushes it down. Anchored under the burger, sized to its contents.

     The panel stays laid out and painted at all times; only its visibility
     changes. Toggling `display` here left stale pixels on iOS: once closed the
     panel was out of layout and hit testing, so it was unclickable, but the
     compositor never repainted the region and it stayed on screen until a reload.
     It is absolutely positioned, so keeping it in flow costs nothing, and
     visibility:hidden removes it from hit testing, tab order and the
     accessibility tree just as display:none would. */
  .menu > .menu-panel {
    position: absolute;
    top: calc(100% - 0.25rem);
    right: 0.35rem;
    min-width: 13.5rem;
    background: var(--bg);
    border: 1px solid var(--rule-hi);
    border-radius: 6px;
    box-shadow: 0 10px 28px rgb(0 0 0 / 0.14), 0 2px 6px rgb(0 0 0 / 0.08);
    padding: 0.35rem;
    margin-top: 0;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    /* No transition. `visibility` is a discrete property, and WebKit mishandles it
       when transitioned alongside opacity: the panel could be left painted after
       being hidden, which is the iPhone-only ghost this removes. An instant hide is
       also the correct behaviour for a menu being dismissed. */
  }

  .menu[open] > .menu-panel {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
  }

  /* Contents stays off the phone. In a compact dropdown eleven extra anchors is
     exactly the giant panel this replaces. */
  .toc { display: none; }

  /* Portrait beside the name instead of above it, which reclaims most of a
     screenful of vertical space before any content is read. */
  .masthead {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    column-gap: 1rem;
    align-items: start;
  }
  .portrait { grid-column: 1; grid-row: 1 / span 3; margin-bottom: 0; width: 92px; height: 92px; }
  .masthead h1, .masthead .role-line, .masthead .mast-meta { grid-column: 2; }
  .masthead .mast-meta { margin-top: 0.1rem; }

  /* Dropdown items: a plain vertical list, which is what a dropdown is. Labels
     stay because a menu the visitor opened deliberately should be readable rather
     than a row of guessable glyphs. No borders per item; the panel is the frame. */
  .side-actions {
    display: block;
    border-top: 0;
    padding-top: 0;
    margin-top: 0;
    font-size: 0.9375rem;
  }

  /* Both the plain and the .btn variants are listed so every item shares one
     padding. The base `a:not(.btn)` rule carries two classes and would otherwise
     outrank a single-class `> a`, leaving the icons on two different left edges. */
  .side-actions > a,
  .side-actions > a:not(.btn) {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.6rem;
    padding: 0.6rem 0.65rem;
    min-height: 42px;                    /* thumb target */
    margin: 0;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: var(--fg);
    font-family: var(--sans);
    font-size: 0.9375rem;
    letter-spacing: 0;
  }
  .side-actions > a:hover,
  .side-actions > a:focus-visible { background: var(--panel); color: var(--accent); }

  /* The two documents read as the primary pair, separated by a hairline.
     Left aligned like every other item: the base .side-actions .btn centring rule
     is more specific than `> a`, so it has to be undone explicitly here. */
  .side-actions > a.btn { justify-content: flex-start; font-weight: 600; }
  .side-actions > .btn.ghost + a {
    border-top: 1px solid var(--rule);
    border-radius: 0 0 4px 4px;
    margin-top: 0.3rem;
    padding-top: 0.7rem;
  }
  .side-actions .ico { color: var(--muted); }
  .side-actions > a:hover .ico { color: var(--accent); }

  /* Tighter action rows on a phone, where the wide desktop gap wastes a line. */
  .actions { gap: 0.5rem 0.9rem; font-size: 0.9375rem; }

  section { margin-bottom: 2.5rem; }
  h2 { margin-bottom: 1.1rem; }
}

@media (max-width: 30rem) {
  body { padding-left: 1.15rem; padding-right: 1.15rem; font-size: 1rem; }

  .portrait { width: 76px; height: 76px; }
  h1 { font-size: 1.3125rem; }
  .role-line { font-size: 0.75rem; }

  h2 { flex-wrap: wrap; gap: 0.35rem; font-size: 0.875rem; }
  h3 { font-size: 1rem; }
  .lede { font-size: 1.0625rem; }

  /* Tables here are five columns of benchmark data. They scroll inside their own
     box rather than widening the page, and the rule on the right hints at it. */
  .scroll-x {
    border-right: 1px solid var(--rule);
    -webkit-overflow-scrolling: touch;
  }
  table { font-size: 0.875rem; }
  thead th, tbody td { padding-right: 0.7rem; }
  .ev td:first-child { max-width: none; }

  .pull, .note { padding-left: 0.8rem; }
  .pull { padding-right: 0.8rem; }

  .role { margin-bottom: 1.5rem; padding-bottom: 1.25rem; }
  dd { margin-top: 0.25rem; }
}

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

/* ---------------- print ---------------- */
@media print {
  :root {
    --bg:#fff; --panel:#f4f4f4; --fg:#000; --muted:#444;
    --rule:#ccc; --rule-hi:#999; --accent:#000; --accent-bg:#f0f0f0;
  }
  body { padding: 0; font-size: 10pt; }
  /* a contents list and download links are useless on paper */
  .skip, .actions, .toc, .side-actions { display: none; }
  .layout { display: block; }
  .sidebar { position: static; max-height: none; overflow: visible; }
  .masthead { margin-bottom: 1.25rem; }
  section { page-break-inside: avoid; margin-bottom: 1.5rem; }
  .role { page-break-inside: avoid; }
  a { text-decoration: none; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 7.5pt; color: #555; }
}

/* The "Open to collaboration" badge became a mailto link, because it already
   looked like a button and now behaves like one. Inherits .badge for the shape
   and only adds the interactive states. */
.badge-link { text-decoration: none; transition: background-color 0.15s ease, color 0.15s ease; }
.badge-link:hover,
.badge-link:focus-visible { background: var(--accent); color: var(--bg); }

/* Cross-page links in the sidebar, under the in-page contents list. Quieter
   than the numbered sections so the eye still starts on the page it is reading. */
.toc-pages { list-style: none; margin: 0; padding: 0; }
.toc-pages li { margin: 0.3rem 0; }
.toc-pages a { font-size: 0.86rem; }

/* ---------------- subpages ---------------- */

/* Subpages get their own sidebar rather than the homepage one. That sidebar is
   built around a portrait, an eight-section contents list and a stack of filled
   buttons; dropped into a column holding three links the buttons dominate,
   their icons render white because .btn sets colour to the page background, and
   the double rule under an empty masthead reads as a mistake. A subpage needs a
   way back and a way around, so that is all it has. */
.page-nav { font-family: var(--mono); font-size: 0.8125rem; }

.page-nav .back {
  display: inline-block;
  color: var(--fg);
  text-decoration: none;
  font-weight: 600;
  letter-spacing: -0.01em;
  padding-bottom: 0.9rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--rule);
  width: 100%;
}
.page-nav .back::before { content: "\2190"; margin-right: 0.4rem; color: var(--muted); }
.page-nav .back:hover,
.page-nav .back:focus-visible { color: var(--accent); }
.page-nav .back:hover::before { color: var(--accent); }

.page-nav-head {
  font-size: 0.6875rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.5rem;
}

.page-nav ol { list-style: none; margin: 0; padding: 0; counter-reset: pn; }
.page-nav li { counter-increment: pn; margin: 0.35rem 0; }
.page-nav a { color: var(--muted); text-decoration: none; }
.page-nav li a::before {
  content: counter(pn, decimal-leading-zero) " ";
  color: var(--rule-hi);
}
.page-nav a:hover,
.page-nav a:focus-visible { color: var(--accent); }

/* The page title moves into <main> on subpages: it is the document's heading,
   not sidebar furniture, and a crawler reading main content should find it
   there. */
.page-head { margin-bottom: 2rem; }
.page-head h1 { font-size: clamp(1.5rem, 4vw, 1.9375rem); margin-bottom: 0.6rem; }
.page-head .lede { margin-bottom: 0; color: var(--muted); }

/* Stacked, and no longer sticky, once the grid collapses to one column. */
@media (max-width: 62rem) {
  .page-nav .back { padding-bottom: 0.7rem; margin-bottom: 0.7rem; }
  .page-nav ol { display: flex; flex-wrap: wrap; gap: 0.35rem 1rem; }
  .page-nav li { margin: 0; }
}
