/* ==========================================================
   Najeeb Jebreel — personal academic site
   One stylesheet for the EN / CA / AR (RTL) pages.
   Layout uses logical properties so RTL mirrors automatically.
   ========================================================== */

:root {
  --paper:      #f4f5f2;
  --surface:    #ffffff;
  --ink:        #17212b;
  --ink-soft:   #3a4652;
  --muted:      #5b6670;
  --rule:       #d9ddd8;
  --cell:       #dfe2dd;
  --cell-mid:   #b9bfba;
  --signal:     #3a36c4;
  --signal-ink: #ffffff;

  --serif: 'Newsreader', 'Iowan Old Style', Georgia, serif;
  --sans:  'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;

  --wrap: 1120px;
  --gutter: clamp(20px, 4vw, 40px);
  --label-col: 200px;
  --header-h: 60px;
}

:root[lang="ar"] {
  --serif: 'Noto Naskh Arabic', 'Newsreader', Georgia, serif;
  --sans:  'IBM Plex Sans Arabic', 'IBM Plex Sans', system-ui, sans-serif;
}

[data-theme="dark"] {
  --paper:      #12171d;
  --surface:    #1a2129;
  --ink:        #e4e8ec;
  --ink-soft:   #c3cad1;
  --muted:      #93a0ac;
  --rule:       #2a333d;
  --cell:       #232b34;
  --cell-mid:   #3a4552;
  --signal:     #a6a2ff;
  --signal-ink: #12171d;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 16px); }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.03rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "kern";
}
:root[lang="ar"] body { font-size: 1.06rem; line-height: 1.85; }

h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img { display: block; max-width: 100%; }

a { color: inherit; text-decoration-line: underline; text-decoration-thickness: 1px;
    text-underline-offset: .18em; text-decoration-color: color-mix(in srgb, currentColor 35%, transparent); }
a:hover { color: var(--signal); text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 3px; border-radius: 2px; }

cite { font-style: italic; }
:root[lang="ar"] cite { font-style: normal; }
:root[lang="ar"] cite:lang(en), :root[lang="ar"] [lang="en"] cite { font-style: italic; }

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

.skip-link { position: absolute; inset-inline-start: 12px; top: -48px; background: var(--ink); color: var(--paper);
             padding: 8px 12px; z-index: 100; text-decoration: none; }
.skip-link:focus { top: 12px; }

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(1.2) blur(8px);
  -webkit-backdrop-filter: saturate(1.2) blur(8px);
  border-bottom: 1px solid var(--rule);
}
.site-header .wrap { height: var(--header-h); display: flex; align-items: center; gap: 24px; }
.wordmark { font-family: var(--serif); font-size: 1.25rem; font-weight: 500; text-decoration: none; letter-spacing: -.005em; white-space: nowrap; }
.wordmark:hover { color: var(--ink); }

.nav { margin-inline-start: auto; }
.nav ul { display: flex; gap: 22px; }
.nav a { text-decoration: none; font-size: .93rem; color: var(--ink-soft); padding-block: 4px; border-bottom: 1px solid transparent; }
.nav a:hover { color: var(--ink); }
.nav a[aria-current="true"] { color: var(--ink); border-bottom-color: var(--ink); }

.tools { display: flex; align-items: center; gap: 4px; padding-inline-start: 18px; border-inline-start: 1px solid var(--rule); }
.lang { display: flex; gap: 2px; }
.lang a, .lang span { font-size: .86rem; padding: 4px 7px; text-decoration: none; color: var(--muted); border-radius: 3px; }
.lang a:hover { color: var(--ink); background: var(--cell); }
.lang [aria-current="page"] { color: var(--ink); font-weight: 600; }
.lang .ar { font-family: 'IBM Plex Sans Arabic', var(--sans); }

.icon-btn { appearance: none; border: 0; background: none; color: var(--ink-soft); width: 36px; height: 36px;
            display: inline-grid; place-items: center; border-radius: 4px; cursor: pointer; }
.icon-btn:hover { background: var(--cell); color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; }
.menu-btn { display: none; }
.theme-btn .sun { display: none; }
[data-theme="dark"] .theme-btn .sun { display: block; }
[data-theme="dark"] .theme-btn .moon { display: none; }

/* ---------- hero ---------- */
.hero { padding-block: clamp(48px, 9vw, 104px) 40px; }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: clamp(28px, 5vw, 72px); align-items: end; }
.hero h1 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(3rem, 7.4vw, 6rem);
  line-height: .95;
  letter-spacing: -.025em;
  font-variation-settings: "opsz" 72;
}
:root[lang="ar"] .hero h1 { letter-spacing: 0; line-height: 1.25; font-weight: 500; font-size: clamp(2.8rem, 6.6vw, 5.2rem); }
.hero .role { margin-top: 22px; color: var(--muted); font-size: 1rem; max-width: 60ch; }
.hero .statement {
  margin-top: 18px;
  font-family: var(--serif);
  font-size: clamp(1.3rem, 2.3vw, 1.65rem);
  line-height: 1.38;
  max-width: 34ch;
  color: var(--ink-soft);
  font-variation-settings: "opsz" 24;
}
:root[lang="ar"] .hero .statement { line-height: 1.75; max-width: 40ch; }
.hero .links { margin-top: 28px; display: flex; flex-wrap: wrap; gap: 6px 20px; font-size: .95rem; }
.hero .links a { color: var(--ink); }
.portrait { width: clamp(150px, 18vw, 210px); aspect-ratio: 4 / 5; object-fit: cover; object-position: 50% 32%;
            border-radius: 3px; filter: saturate(.85); }

/* The sample field: one square per training sample; a few light up. */
.samples { margin-top: clamp(40px, 6vw, 64px); }
.sample-field { display: grid; grid-template-columns: repeat(var(--cols, 60), 1fr); gap: 3px; direction: ltr; }
.sample-field i { display: block; aspect-ratio: 1; background: var(--cell); border-radius: 1px; }
.sample-field i.m { background: var(--cell-mid); }
.sample-field i.v { background: var(--cell); transition: background-color .5s ease, transform .5s ease; }
.sample-field.lit i.v { background: var(--signal); }
.samples figcaption { margin-top: 14px; font-size: .92rem; color: var(--muted); max-width: 68ch; }
.samples .key { display: inline-block; width: .7em; height: .7em; background: var(--signal); vertical-align: baseline; margin-inline-end: .4em; border-radius: 1px; }

/* ---------- sections ---------- */
.sec { border-top: 1px solid var(--rule); padding-block: clamp(48px, 7vw, 84px); }
.sec > .wrap { display: grid; grid-template-columns: var(--label-col) minmax(0, 1fr); gap: 24px clamp(28px, 4vw, 56px); }
.sec h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.9rem;
  line-height: 1.15;
  letter-spacing: -.01em;
  align-self: start;
  position: sticky; top: calc(var(--header-h) + 28px);
}
:root[lang="ar"] .sec h2 { letter-spacing: 0; font-weight: 500; font-size: 1.75rem; line-height: 1.5; }
.sec-body { max-width: 760px; min-width: 0; }

.prose p + p { margin-top: 1em; }
.prose p { max-width: 70ch; }

h3.sub { font-family: var(--sans); font-size: 1rem; font-weight: 600; margin: 0 0 14px; color: var(--ink); }
.sec-body > h3.sub:not(:first-child) { margin-top: 44px; }
.note { margin-top: 22px; font-size: .9rem; color: var(--muted); }

/* ---------- news ---------- */
.news li { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 16px; padding-block: 11px; border-bottom: 1px solid var(--rule); }
.news li:first-child { padding-top: 0; }
.news time { color: var(--muted); font-size: .92rem; font-variant-numeric: tabular-nums; padding-top: 1px; white-space: nowrap; }
.more { margin-top: 6px; }
.more > summary { cursor: pointer; list-style: none; padding-block: 12px; color: var(--ink-soft); font-size: .95rem; width: fit-content; }
.more > summary::-webkit-details-marker { display: none; }
.more > summary::before { content: "+"; display: inline-block; width: 1.1em; font-weight: 600; }
.more[open] > summary::before { content: "\2212"; }
.more > summary:hover { color: var(--ink); }

/* ---------- research ---------- */
.themes > li { padding-block: 26px; border-bottom: 1px solid var(--rule); }
.themes > li:first-child { padding-top: 0; }
.themes h3 { font-family: var(--serif); font-weight: 500; font-size: 1.35rem; line-height: 1.3; margin-bottom: 10px; }
:root[lang="ar"] .themes h3 { font-size: 1.3rem; line-height: 1.6; }
.themes p { max-width: 70ch; }
.themes .key-papers { margin-top: 12px; font-size: .92rem; color: var(--muted); }
.themes .key-papers a { color: var(--ink-soft); }

/* ---------- publications ---------- */
.filters { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 6px; margin-bottom: 30px; font-size: .92rem; }
.filters .label { color: var(--muted); margin-inline-end: 6px; }
.filters button {
  appearance: none; font: inherit; color: var(--ink-soft); background: none;
  border: 1px solid var(--rule); border-radius: 999px; padding: 3px 12px; cursor: pointer;
}
.filters button:hover { border-color: var(--ink-soft); color: var(--ink); }
.filters button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.filters .count { margin-inline-start: auto; color: var(--muted); font-variant-numeric: tabular-nums; }

.year { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 16px; }
.year + .year { margin-top: 8px; }
.year > h3 {
  font-family: var(--serif); font-weight: 400; font-size: 1.25rem; color: var(--muted);
  font-variant-numeric: lining-nums tabular-nums; padding-top: 14px; line-height: 1.2;
}
.pubs > li { padding-block: 14px 16px; border-bottom: 1px solid var(--rule); }
.year[hidden], .pubs > li[hidden] { display: none; }
.pub-title { font-weight: 600; font-size: 1.02rem; line-height: 1.4; color: var(--ink); }
.pub-authors { margin-top: 3px; font-size: .94rem; color: var(--muted); }
.pub-authors b { color: var(--ink); font-weight: 600; }
.pub-venue { margin-top: 2px; font-size: .94rem; color: var(--ink-soft); }
.pub-venue em { font-style: italic; }
.pub-meta { margin-top: 8px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; font-size: .86rem; }
.pub-meta .links { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.pub-meta .links a { color: var(--ink); }
.pub-meta .cites { color: var(--muted); font-variant-numeric: tabular-nums; }
.tag { display: inline-block; font-size: .78rem; line-height: 1.5; padding: 0 7px; border: 1px solid var(--rule); border-radius: 3px; color: var(--ink-soft); white-space: nowrap; }
.tag.award { background: var(--signal); border-color: var(--signal); color: var(--signal-ink); font-weight: 600; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.pub-note { margin-top: 6px; font-size: .88rem; color: var(--muted); }

.all-pubs { margin-top: 28px; font-size: .95rem; }

/* ---------- CV / projects rows ---------- */
.rows > li { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 16px; padding-block: 11px; border-bottom: 1px solid var(--rule); }
.rows > li:first-child { padding-top: 0; }
.rows .when { color: var(--muted); font-size: .92rem; font-variant-numeric: tabular-nums; padding-top: 1px; }
.rows .what { font-weight: 600; }
.rows .where { color: var(--ink-soft); font-size: .95rem; }
.rows .detail { color: var(--muted); font-size: .93rem; margin-top: 2px; }
.rows .detail ul { margin-top: 4px; }
.rows > li > div > .detail { margin-top: 2px; }
.rows .detail li { padding-block: 1px; }
.cv-cols { display: grid; grid-template-columns: 1fr; gap: 0; }

/* ---------- contact ---------- */
.contact { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 28px; }
.contact h3 { font-size: .9rem; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.contact address { font-style: normal; }
.contact ul li { padding-block: 1px; }
.contact .email { font-family: var(--serif); font-size: 1.35rem; }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--rule); padding-block: 28px 40px; font-size: .88rem; color: var(--muted); }
.site-footer .wrap { display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between; }

/* ---------- responsive ---------- */
@media (max-width: 1020px) {
  .nav ul { gap: 16px; }
}
@media (max-width: 900px) {
  .menu-btn { display: inline-grid; }
  .nav {
    position: absolute; top: var(--header-h); inset-inline: 0;
    background: var(--paper); border-bottom: 1px solid var(--rule);
    display: none; margin: 0;
  }
  .nav.open { display: block; }
  .nav ul { flex-direction: column; gap: 0; padding: 8px var(--gutter) 16px; }
  .nav a { display: block; padding-block: 10px; font-size: 1rem; border: 0; }
  .tools { margin-inline-start: auto; }
  .sec > .wrap { grid-template-columns: 1fr; }
  .sec h2 { position: static; }
}
@media (max-width: 640px) {
  .hero-grid { grid-template-columns: 1fr; }
  .portrait { grid-row: 1; width: 120px; }
  .tools { padding-inline-start: 8px; }
  .wordmark { font-size: 1.1rem; }
  .news li, .rows > li { grid-template-columns: 1fr; gap: 2px; }
  .year { grid-template-columns: 1fr; gap: 0; }
  .year > h3 { padding-top: 18px; }
  .filters .count { margin-inline-start: 0; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

@media print {
  .site-header, .samples, .filters, .more > summary { display: none !important; }
  .more > *:not(summary) { display: block !important; }
  .sec { padding-block: 18px; break-inside: avoid-page; }
  .sec h2 { position: static; }
  body { background: #fff; color: #000; }
}
