/* Kareem Samir: Redacted identity, crimson accent. CSS only (no JavaScript), self-hosted fonts. */

@font-face {
  font-family: "Archivo";
  src: url("/fonts/archivo-latin-wdth-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/fonts/jetbrains-mono-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --paper: #e9ebee;       /* page */
  --doc: #ffffff;         /* header, cards */
  --ink: #121418;         /* text */
  --red: #8f001a;         /* deep crimson: text, bars, edges */
  --red-fill: #8f001a;    /* fills under white text (button, selection) */
  --steel: #5a6472;       /* secondary text */
  --rule: #d3d7dc;
  --tint: rgba(143, 0, 26, 0.06);
  --lift: 0 10px 24px -14px rgba(18, 20, 24, 0.45);

  --sans: "Archivo", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;
  --wrap: 1120px;
  --label: 240px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --glitch-every: 6s;     /* the mark and the name glitch on this interval */
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0a0b0d;
    --doc: #14161a;
    --ink: #e9ebee;
    --red: #f0364c;         /* deepest red that keeps text contrast on dark */
    --red-fill: #8f001a;    /* deep crimson stays under white text */
    --steel: #9aa3af;
    --rule: #262a31;
    --tint: rgba(240, 54, 76, 0.08);
    --lift: 0 12px 26px -14px rgba(0, 0, 0, 0.9);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper) url("/bg-network-light.svg") repeat;   /* faint network map: tools/make_backgrounds.py */
  color: var(--ink);
  font-family: var(--sans);
  font-stretch: 87.5%;
  font-size: 17px;
  line-height: 1.6;
}
@media (prefers-color-scheme: dark) { body { background-image: url("/bg-network-dark.svg"); } }
@media (forced-colors: active), (prefers-contrast: more) { body { background-image: none; } }
h1, h2, h3, p { margin: 0; }
ul, ol, dl, dd { margin: 0; padding: 0; }
ul, ol { list-style: none; }
strong { font-weight: 700; }

a { color: var(--red); text-decoration-thickness: 1px; text-underline-offset: 0.2em; transition: color 160ms var(--ease), text-decoration-color 160ms var(--ease); }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 3px; border-radius: 2px; }
::selection { background: var(--red-fill); color: #ffffff; }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.cert-code { font-family: var(--mono); font-stretch: normal; }

/* Skip link: fully hidden until a keyboard user tabs to it */
.skip { position: absolute; left: 16px; top: 12px; z-index: 30; padding: 10px 14px; background: var(--ink); color: var(--doc); font-weight: 700; text-decoration: none; }
.skip:not(:focus-visible) { width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }

.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 32px; }
@media (max-width: 600px) { .wrap { padding: 0 16px; } }

/* ---------- Glitch ----------
   One set of keyframes drives both the header mark and the name, so they glitch the same way.
   --g is the step size: 1px for the 32px mark, a fraction of an em for the name.
   *-loop versions squeeze the glitch into the first 10% of --glitch-every and then rest. */
@keyframes g-jolt {
  0%   { transform: translate(0, 0); }
  12%  { transform: translate(calc(var(--g) * -2), var(--g)); }
  24%  { transform: translate(calc(var(--g) * 2), calc(var(--g) * -1)); }
  36%  { transform: translate(calc(var(--g) * -1), 0); }
  48%  { transform: translate(calc(var(--g) * 2), var(--g)); }
  60%  { transform: translate(calc(var(--g) * -2), calc(var(--g) * -1)); }
  72%, 100% { transform: translate(0, 0); }
}
@keyframes g-red {
  0%   { opacity: 1; clip-path: inset(8% 0 72% 0);  transform: translateX(calc(var(--g) * -3)); }
  14%  { opacity: 1; clip-path: inset(58% 0 24% 0); transform: translateX(calc(var(--g) * -1)); }
  28%  { opacity: 1; clip-path: inset(32% 0 50% 0); transform: translateX(calc(var(--g) * -4)); }
  42%  { opacity: 1; clip-path: inset(74% 0 6% 0);  transform: translateX(calc(var(--g) * -2)); }
  56%  { opacity: 1; clip-path: inset(40% 0 42% 0); transform: translateX(calc(var(--g) * -3)); }
  70%  { opacity: 1; clip-path: inset(14% 0 78% 0); transform: translateX(calc(var(--g) * -1)); }
  84%, 100% { opacity: 0; clip-path: inset(50% 0 50% 0); transform: translateX(0); }
}
@keyframes g-slice {
  0%   { opacity: 1; clip-path: inset(44% 0 40% 0); transform: translateX(calc(var(--g) * 3)); }
  14%  { opacity: 1; clip-path: inset(10% 0 80% 0); transform: translateX(calc(var(--g) * -3)); }
  28%  { opacity: 1; clip-path: inset(66% 0 18% 0); transform: translateX(calc(var(--g) * 4)); }
  42%  { opacity: 1; clip-path: inset(24% 0 62% 0); transform: translateX(calc(var(--g) * -2)); }
  56%  { opacity: 1; clip-path: inset(80% 0 4% 0);  transform: translateX(calc(var(--g) * 2)); }
  70%  { opacity: 1; clip-path: inset(52% 0 36% 0); transform: translateX(calc(var(--g) * -4)); }
  84%, 100% { opacity: 0; clip-path: inset(50% 0 50% 0); transform: translateX(0); }
}
@keyframes g-jolt-loop {
  0%   { transform: translate(0, 0); }
  1.2% { transform: translate(calc(var(--g) * -2), var(--g)); }
  2.4% { transform: translate(calc(var(--g) * 2), calc(var(--g) * -1)); }
  3.6% { transform: translate(calc(var(--g) * -1), 0); }
  4.8% { transform: translate(calc(var(--g) * 2), var(--g)); }
  6%   { transform: translate(calc(var(--g) * -2), calc(var(--g) * -1)); }
  7.2%, 100% { transform: translate(0, 0); }
}
@keyframes g-red-loop {
  0%   { opacity: 1; clip-path: inset(8% 0 72% 0);  transform: translateX(calc(var(--g) * -3)); }
  1.4% { opacity: 1; clip-path: inset(58% 0 24% 0); transform: translateX(calc(var(--g) * -1)); }
  2.8% { opacity: 1; clip-path: inset(32% 0 50% 0); transform: translateX(calc(var(--g) * -4)); }
  4.2% { opacity: 1; clip-path: inset(74% 0 6% 0);  transform: translateX(calc(var(--g) * -2)); }
  5.6% { opacity: 1; clip-path: inset(40% 0 42% 0); transform: translateX(calc(var(--g) * -3)); }
  7%   { opacity: 1; clip-path: inset(14% 0 78% 0); transform: translateX(calc(var(--g) * -1)); }
  8.4%, 100% { opacity: 0; clip-path: inset(50% 0 50% 0); transform: translateX(0); }
}
@keyframes g-slice-loop {
  0%   { opacity: 1; clip-path: inset(44% 0 40% 0); transform: translateX(calc(var(--g) * 3)); }
  1.4% { opacity: 1; clip-path: inset(10% 0 80% 0); transform: translateX(calc(var(--g) * -3)); }
  2.8% { opacity: 1; clip-path: inset(66% 0 18% 0); transform: translateX(calc(var(--g) * 4)); }
  4.2% { opacity: 1; clip-path: inset(24% 0 62% 0); transform: translateX(calc(var(--g) * -2)); }
  5.6% { opacity: 1; clip-path: inset(80% 0 4% 0);  transform: translateX(calc(var(--g) * 2)); }
  7%   { opacity: 1; clip-path: inset(52% 0 36% 0); transform: translateX(calc(var(--g) * -4)); }
  8.4%, 100% { opacity: 0; clip-path: inset(50% 0 50% 0); transform: translateX(0); }
}

/* Header */
.site-header { position: sticky; top: 0; z-index: 10; background: var(--doc); border-bottom: 1px solid var(--rule); }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 60px; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; }
.wordmark { font-weight: 800; font-size: 18px; letter-spacing: -0.01em; }

/* Header mark: the slash-cut KS. The interval glitch runs on .mark and its layers; hover and
   focus replay it on .mark-wrap's layers, so leaving the link never restarts anything. */
.mark-wrap { --g: 1px; position: relative; display: block; flex: none; width: 32px; height: 32px; }
.mark, .mark::before, .mark::after, .mark-wrap::before, .mark-wrap::after {
  position: absolute; inset: 0; background: url("/logo.svg") center / contain no-repeat;
}
.mark::before, .mark::after, .mark-wrap::before, .mark-wrap::after { content: ""; opacity: 0; pointer-events: none; }
.mark::before, .mark-wrap::before { background-image: url("/logo-red.svg"); }
.mark-wrap::before, .mark-wrap::after { z-index: 1; }
.mark { animation: g-jolt-loop var(--glitch-every) steps(1, end) infinite; }
.mark::before { animation: g-red-loop var(--glitch-every) steps(1, end) infinite; }
.mark::after { animation: g-slice-loop var(--glitch-every) steps(1, end) infinite; }
.brand:hover .mark-wrap, .brand:focus-visible .mark-wrap { animation: g-jolt 600ms steps(1, end); }
.brand:hover .mark-wrap::before, .brand:focus-visible .mark-wrap::before { animation: g-red 600ms steps(1, end); }
.brand:hover .mark-wrap::after, .brand:focus-visible .mark-wrap::after { animation: g-slice 600ms steps(1, end); }

.nav { display: flex; gap: 26px; font-size: 15px; font-weight: 500; }
.nav a { position: relative; display: inline-block; padding: 4px 0; color: var(--ink); text-decoration: none; }
.nav a::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--red); transform: scaleX(0); transform-origin: left; transition: transform 200ms var(--ease); }
.nav a:hover::after, .nav a:focus-visible::after { transform: scaleX(1); }
/* Contact: the one call to action in the header, a small outlined button */
.nav .nav-cta a { padding: 4px 12px; border: 1px solid var(--red); transition: background-color 160ms var(--ease), color 160ms var(--ease); }
.nav .nav-cta a::after { content: none; }
.nav .nav-cta a:hover, .nav .nav-cta a:focus-visible { background: var(--red-fill); border-color: var(--red-fill); color: #fff; }
@media (max-width: 640px) { .nav { gap: 16px; font-size: 14px; } .nav li:nth-child(2) { display: none; } }
@media (max-width: 420px) { .nav li:nth-child(3) { display: none; } }

/* Hero */
.hero { padding-top: 88px; padding-bottom: 72px; }
.kicker { font-weight: 700; font-size: 16px; color: var(--red); }
.hero h1 {
  margin-top: 10px;
  font-size: clamp(48px, 9vw, 104px); line-height: 0.95; font-weight: 800; letter-spacing: -0.03em;
}
/* Name: the same glitch as the mark. A red copy and a slice copy come from data-text with empty
   alt text, so screen readers read the name once. Interval on the h1, hover replay on the span. */
.glitch { --g: 0.02em; position: relative; display: inline-block; animation: g-jolt-loop var(--glitch-every) steps(1, end) infinite; }
.glitch-hover { position: relative; display: inline-block; }
.glitch::before, .glitch::after, .glitch-hover::before, .glitch-hover::after {
  content: attr(data-text);
  content: attr(data-text) / "";
  position: absolute; left: 0; top: 0; width: 100%; height: 100%;
  opacity: 0; pointer-events: none;
}
.glitch::before, .glitch-hover::before { color: var(--red); }                               /* like logo-red.svg */
.glitch::after, .glitch-hover::after { color: var(--ink); background: var(--paper); }       /* like the tiled slice */
.glitch::before { animation: g-red-loop var(--glitch-every) steps(1, end) infinite; }
.glitch::after { animation: g-slice-loop var(--glitch-every) steps(1, end) infinite; }
.glitch:hover .glitch-hover { animation: g-jolt 600ms steps(1, end); }
.glitch:hover .glitch-hover::before { animation: g-red 600ms steps(1, end); }
.glitch:hover .glitch-hover::after { animation: g-slice 600ms steps(1, end); }
.lede { margin-top: 28px; max-width: 58ch; font-size: clamp(18px, 2vw, 21px); line-height: 1.55; }

/* Sections: heading on the left, content on the right */
.section { display: grid; grid-template-columns: var(--label) minmax(0, 1fr); gap: 40px; padding-top: 56px; padding-bottom: 56px; scroll-margin-top: 70px; }
.section h2 { font-size: 28px; line-height: 1.15; font-weight: 800; letter-spacing: -0.015em; }
.section h2::before { content: ""; display: block; width: 44px; height: 10px; margin-bottom: 16px; background: var(--red); transform-origin: left; transition: width 200ms var(--ease); }
.section:hover h2::before { width: 92px; }
@media (max-width: 860px) { .section { grid-template-columns: 1fr; gap: 22px; padding-top: 44px; padding-bottom: 44px; } }

/* Experience */
.role-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 24px; align-items: baseline; }
.role-head h3 { grid-column: 1; font-size: 22px; font-weight: 800; letter-spacing: -0.01em; }
.role-dates { grid-column: 2; grid-row: 1; font-family: var(--mono); font-stretch: normal; font-size: 14px; color: var(--steel); white-space: nowrap; }
@media (max-width: 480px) { .role-head { grid-template-columns: 1fr; } .role-dates { grid-column: 1; grid-row: auto; margin-top: 2px; } }
.role-org { grid-column: 1; color: var(--steel); font-weight: 500; }
.role-org span { margin: 0 4px; }
.org-link { font-family: var(--mono); font-stretch: normal; font-size: 14px; font-weight: 500; }
.role-focus { margin-top: 12px; font-size: 18px; font-weight: 600; color: var(--ink); }
.role-list { margin-top: 18px; display: grid; gap: 9px; }
.role-list li { position: relative; padding-left: 22px; max-width: 70ch; }
.role-list li::before { content: ""; position: absolute; left: 1px; top: 0.6em; width: 8px; height: 8px; background: var(--red); }

/* Skills: a red bar slides in and the row tints on hover */
.skill { position: relative; display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 24px; padding: 16px 14px 16px 20px; border-top: 1px solid var(--rule); transition: background-color 180ms var(--ease); }
.skill:first-child { border-top: 0; }
.skill::before { content: ""; position: absolute; left: 0; top: 12px; bottom: 12px; width: 4px; background: var(--red); opacity: 0; transform: translateX(-8px); transition: transform 180ms var(--ease), opacity 180ms var(--ease); }
.skill:hover { background: var(--tint); }
.skill:hover::before { opacity: 1; transform: translateX(0); }
.skill dt { font-weight: 800; }
.skill dd { color: var(--steel); }
@media (max-width: 600px) { .skill { grid-template-columns: 1fr; gap: 4px; } }

/* Certifications: every card leads with its certificate artwork (like the Pro Labs), the official
   certificate opens in a popover. Cards lift, the red edge thickens, the banner zooms a touch. */
.certs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.certs-labs { margin-top: 12px; }
.cert { position: relative; display: flex; flex-direction: column; background: var(--doc); border: 1px solid var(--rule); overflow: hidden; transition: transform 180ms var(--ease), box-shadow 180ms var(--ease); }
.cert::before { content: ""; position: absolute; z-index: 1; left: 0; top: 0; bottom: 0; width: 4px; background: var(--red); transition: width 180ms var(--ease); }
.cert:hover { transform: translateY(-2px); box-shadow: var(--lift); }
.cert:hover::before { width: 7px; }
.cert-banner { display: block; width: 100%; aspect-ratio: 3 / 1; padding: 0; border: 0; background: #16191e; overflow: hidden; cursor: zoom-in; }
.cert-banner img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform 200ms var(--ease); }
.cert:hover .cert-banner img { transform: scale(1.04); }
.cert-progress { border-style: dashed; }
.cert-progress .cert-banner { cursor: default; }
.cert-body { display: flex; flex: 1; flex-direction: column; gap: 3px; padding: 14px 18px 16px 22px; }
.cert-code { font-size: 18px; font-weight: 700; }
.cert-name { font-weight: 700; line-height: 1.3; }
.cert-meta { font-size: 15px; color: var(--steel); }
.cert-actions { margin-top: auto; padding-top: 10px; display: flex; flex-wrap: wrap; gap: 4px 18px; align-items: baseline; }
.cert-open { padding: 0; border: 0; background: none; font: inherit; font-size: 15px; font-weight: 700; color: var(--red); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.2em; cursor: zoom-in; }
.cert-open:hover { text-decoration-thickness: 2px; }
.cert-verify { font-weight: 700; font-size: 15px; }
.cert-verify::after { content: "↗"; display: inline-block; margin-left: 4px; transition: transform 180ms var(--ease); }
.cert:hover .cert-verify::after { transform: translateX(3px); }
.cert-status { margin-top: auto; padding-top: 10px; font-weight: 700; font-size: 15px; color: var(--red); }
.cert-status::before { content: ""; display: inline-block; width: 9px; height: 9px; margin-right: 8px; background: var(--red); vertical-align: 0.05em; }
@media (max-width: 680px) { .certs { grid-template-columns: 1fr; } }

/* Certificate popover: centred in the top layer, light-dismiss (click outside or Esc) */
.cert-pop { margin: auto; padding: 0; border: 0; background: transparent; overflow: visible; max-width: none;
  opacity: 0; transform: scale(.97); transition: opacity 180ms var(--ease), transform 180ms var(--ease), overlay 180ms allow-discrete, display 180ms allow-discrete; }
.cert-pop:popover-open { opacity: 1; transform: none; }
@starting-style { .cert-pop:popover-open { opacity: 0; transform: scale(.97); } }
.cert-pop img { display: block; width: auto; height: auto; max-width: min(92vw, 1000px); max-height: 84vh; background: #ffffff; box-shadow: 0 30px 80px -24px rgba(0, 0, 0, 0.7); }
.cert-pop::backdrop { background: rgba(10, 11, 13, 0.78); }
.cert-close { position: absolute; right: 0; bottom: calc(100% + 10px); padding: 8px 14px; border: 0; background: var(--red-fill); color: #ffffff; font: inherit; font-size: 14px; font-weight: 700; cursor: pointer; }
.cert-close:hover { background: #ffffff; color: #121418; }
.subhead { margin-top: 30px; margin-bottom: 4px; font-size: 18px; font-weight: 800; }

/* Contact */
.contact-lede { font-size: clamp(22px, 2.6vw, 28px); line-height: 1.3; font-weight: 700; letter-spacing: -0.01em; }
.contact-links { margin-top: 24px; display: flex; flex-wrap: wrap; gap: 12px; }
.btn { display: inline-flex; align-items: center; min-height: 48px; padding: 10px 20px; font-weight: 700; text-decoration: none; overflow-wrap: anywhere; border: 2px solid transparent; transition: background-color 160ms var(--ease), color 160ms var(--ease), border-color 160ms var(--ease); }
.btn-solid { background: var(--red-fill); color: #ffffff; }
.btn-solid:hover { background: var(--ink); color: var(--doc); }
.btn-line { border-color: var(--ink); color: var(--ink); }
.btn-line:hover { border-color: var(--red); color: var(--red); }

/* Footer */
.site-footer { border-top: 1px solid var(--rule); padding: 24px 0 36px; color: var(--steel); font-size: 14px; }
.footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; }
.to-top { font-weight: 700; }

/* 404 */
.notfound { padding-top: 88px; padding-bottom: 96px; }
.notfound h1 { margin-top: 8px; font-size: clamp(40px, 7vw, 72px); line-height: 1; font-weight: 800; letter-spacing: -0.02em; }
.notfound p { margin-top: 14px; max-width: 50ch; }
.notfound .btn { margin-top: 28px; }

/* Scroll: section bars draw in and content rises into place as it enters the viewport.
   Browsers without scroll-driven animations simply show everything in place. The animations use
   the separate `translate` property so they never fight the hover transforms. */
@keyframes bar-in { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes rise-in { from { opacity: 0; translate: 0 18px; } to { opacity: 1; translate: 0 0; } }
@keyframes slide-in { from { opacity: 0; translate: -18px 0; } to { opacity: 1; translate: 0 0; } }
@supports (animation-timeline: view()) {
  .section h2::before { animation: bar-in linear both; animation-timeline: view(); animation-range: entry 20% cover 35%; }
  .role-list li, .cert, .contact-links, .role-focus { animation: rise-in linear both; animation-timeline: view(); animation-range: entry 0% entry 80%; }
  .skill { animation: slide-in linear both; animation-timeline: view(); animation-range: entry 0% entry 80%; }
}

/* No motion for people who ask for less */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .cert:hover, .cert:hover .cert-verify::after { transform: none; }
  /* no glitch at all: clean mark and name */
  .mark::before, .mark::after, .mark-wrap::before, .mark-wrap::after,
  .glitch::before, .glitch::after, .glitch-hover::before, .glitch-hover::after { display: none; }
}
