/* ==========================================================================
   Rameen Abdal — personal site
   Cinematic dark, type-led. No frameworks, no webfonts, no external requests.
   ========================================================================== */

/* ---------- tokens ---------- */
:root {
  --bg:        #08080a;
  --bg-raise:  #101013;
  --bg-sunk:   #050506;
  --line:      #1e1e24;
  --line-soft: #16161b;
  --fg:        #f4f4f5;
  --fg-mid:    #a5a5b0;
  --fg-dim:    #6e6e7a;
  --accent:    #e6b166;
  --accent-dim:#8a6a3d;
  --chip:      #ffffff0d;

  --shell: 1180px;
  --gap: clamp(1rem, 2.2vw, 1.75rem);
  --radius: 14px;

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

  --ease: cubic-bezier(.22, .61, .36, 1);
  color-scheme: dark;
}

[data-theme="light"] {
  --bg:        #fbfbfa;
  --bg-raise:  #ffffff;
  --bg-sunk:   #f2f2f0;
  --line:      #e3e3df;
  --line-soft: #ededea;
  --fg:        #14141a;
  --fg-mid:    #55555f;
  --fg-dim:    #85858f;
  --accent:    #9a6b1e;
  --accent-dim:#cfae74;
  --chip:      #0000000a;
  color-scheme: light;
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 5.5rem;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: clamp(0.95rem, 0.4vw + 0.86rem, 1.0625rem);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* subtle vignette so the dark canvas reads as lit, not flat */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(120% 70% at 50% -10%, #ffffff0a, transparent 60%),
    radial-gradient(80% 50% at 100% 0%, var(--accent-dim), transparent 70%);
  opacity: .35;
}
[data-theme="light"] body::before { opacity: .18; }

a { color: inherit; text-decoration: none; }
/* height:auto is required alongside the width/height attrs, or the attribute
   height wins and aspect-ratio is ignored */
img, video { max-width: 100%; height: auto; display: block; }

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

.shell {
  width: 100%;
  max-width: var(--shell);
  margin-inline: auto;
  padding-inline: clamp(1.15rem, 4vw, 2.5rem);
  position: relative;
  z-index: 1;
}

.skip {
  position: absolute; left: -9999px;
  background: var(--accent); color: #0a0a0a;
  padding: .6rem 1rem; border-radius: 0 0 8px 0; font-weight: 600;
}
.skip:focus { left: 0; top: 0; z-index: 99; }

/* ---------- nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color .3s var(--ease);
}
.nav[data-stuck="true"] { border-bottom-color: var(--line); }
.nav__in {
  display: flex; align-items: center; gap: 1.25rem;
  min-height: 3.75rem;
}
.nav__id {
  font-weight: 620; letter-spacing: -.015em; font-size: .98rem;
  margin-right: auto; white-space: nowrap;
}
.nav__id span { color: var(--fg-dim); font-weight: 400; }
.nav__links { display: flex; gap: 1.1rem; overflow-x: auto; scrollbar-width: none; }
.nav__links::-webkit-scrollbar { display: none; }
.nav__links a {
  font-size: .855rem; color: var(--fg-mid); white-space: nowrap;
  padding: .2rem 0; border-bottom: 1px solid transparent;
  transition: color .18s var(--ease), border-color .18s var(--ease);
}
.nav__links a:hover { color: var(--fg); }
.nav__links a[aria-current="true"] { color: var(--fg); border-bottom-color: var(--accent); }

.toggle {
  display: grid; place-items: center;
  width: 2.1rem; height: 2.1rem; flex: 0 0 auto;
  border: 1px solid var(--line); border-radius: 50%;
  background: var(--chip); color: var(--fg-mid); cursor: pointer;
  transition: color .18s var(--ease), border-color .18s var(--ease);
}
.toggle:hover { color: var(--fg); border-color: var(--fg-dim); }
.toggle svg { width: 15px; height: 15px; }
.toggle .i-sun { display: none; }
[data-theme="light"] .toggle .i-sun { display: block; }
[data-theme="light"] .toggle .i-moon { display: none; }

/* Mobile: keep section nav reachable as a scrollable row rather than hiding it.
   Fading the right edge hints that it scrolls. */
@media (max-width: 720px) {
  .nav__in { gap: .75rem; }
  .nav__id { font-size: .9rem; }
  .nav__id span { display: none; }
  .nav__links {
    gap: .9rem;
    -webkit-overflow-scrolling: touch;
    mask-image: linear-gradient(to right, #000 82%, transparent);
  }
  .nav__links a { font-size: .82rem; }
}
@media (max-width: 420px) {
  .nav__id { display: none; }
  .nav__links { margin-right: auto; }
}

/* ---------- hero ---------- */
/* padding-block only — the `padding` shorthand would reset .shell's padding-inline */
.hero { padding-block: clamp(3.5rem, 9vw, 7.5rem) clamp(2.5rem, 5vw, 4rem); }
.hero__name {
  margin: 0 0 .35em;
  font-size: clamp(2.6rem, 8.5vw, 5.75rem);
  line-height: .95;
  letter-spacing: -.038em;
  font-weight: 680;
}
.hero__role {
  margin: 0 0 1.5rem;
  font-size: clamp(1.02rem, 1.5vw, 1.32rem);
  color: var(--fg-mid);
  max-width: 44ch;
  letter-spacing: -.01em;
}
.hero__role b { color: var(--fg); font-weight: 600; }
.hero__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.55fr);
  gap: clamp(1.75rem, 4vw, 3.5rem);
  align-items: start;
}
@media (max-width: 860px) { .hero__grid { grid-template-columns: 1fr; } }

.portrait {
  width: min(100%, 260px);
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  filter: saturate(.95);
}
.bio p { margin: 0 0 1rem; color: var(--fg-mid); }
.bio p:first-child { color: var(--fg); }
.bio a { color: var(--fg); border-bottom: 1px solid var(--accent-dim); transition: border-color .18s var(--ease); }
.bio a:hover { border-bottom-color: var(--accent); }

.socials { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1.25rem; }
.socials a {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .42rem .8rem; border-radius: 999px;
  border: 1px solid var(--line); background: var(--chip);
  font-size: .8rem; color: var(--fg-mid);
  transition: color .18s var(--ease), border-color .18s var(--ease), transform .18s var(--ease);
}
.socials a:hover { color: var(--fg); border-color: var(--fg-dim); transform: translateY(-1px); }
.socials svg { width: 14px; height: 14px; }

/* ---------- section chrome ---------- */
.section { padding-block: clamp(2.75rem, 6vw, 5rem); border-top: 1px solid var(--line-soft); }
.section__head {
  display: flex; align-items: baseline; gap: .9rem;
  margin-bottom: clamp(1.5rem, 3vw, 2.5rem);
}
.section__head h2 {
  margin: 0; font-size: clamp(1.32rem, 2.4vw, 1.85rem);
  letter-spacing: -.025em; font-weight: 640;
}
.section__count {
  font-family: var(--mono); font-size: .74rem; color: var(--fg-dim);
  border: 1px solid var(--line); border-radius: 999px; padding: .1rem .5rem;
}

/* ---------- timeline (education / experience) ----------
   Laid out as one horizontal band per section: all entries side by side,
   stacked logo over text. Far shorter vertically than one row each. */
/* flex, not grid: auto-fit would create more tracks than there are items and
   leave them at minimum width with a ragged right edge. flex-grow fills the row. */
.tl {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  align-items: stretch;
}
.tl__row {
  flex: 1 1 148px;
  display: flex; flex-direction: column; align-items: flex-start;
  gap: .4rem;
  padding: .85rem .75rem;
  border-radius: 12px;
  border: 1px solid var(--line-soft);
  background: var(--bg-raise);
  transition: border-color .2s var(--ease), transform .2s var(--ease);
}
.tl__row:hover { border-color: var(--accent-dim); transform: translateY(-2px); }
/* logos are mixed dark and light artwork, so a white chip keeps each one legible */
/* 64px display; smallest source (NIT, 220px) still has 2x headroom */
.tl__logo {
  width: 4rem; height: 4rem; border-radius: 10px;
  background: #fff; padding: .45rem;
  object-fit: contain; border: 1px solid var(--line);
  margin-bottom: .3rem;
}
.tl__what { font-weight: 580; letter-spacing: -.012em; font-size: .93rem; line-height: 1.3; }
.tl__where { color: var(--fg-mid); font-size: .82rem; line-height: 1.35; }
.tl__when {
  font-family: var(--mono); font-size: .73rem; color: var(--fg-dim);
  margin-top: auto; padding-top: .25rem;
}

/* Narrow screens: go back to one horizontal card per row. Stacked cards two-up
   wrap the location text into 4+ lines and leave a lone stretched card. */
@media (max-width: 560px) {
  .tl__row { flex: 1 1 100%; flex-direction: row; align-items: center; gap: .8rem; }
  .tl__logo { width: 3rem; height: 3rem; margin-bottom: 0; flex: 0 0 auto; }
  .tl__what { font-size: .9rem; }
  .tl__when {
    margin-top: 0; padding-top: 0; margin-left: auto;
    text-align: right; white-space: nowrap;
  }
}

/* ---------- publications ---------- */
.year {
  display: flex; align-items: center; gap: 1rem;
  margin: clamp(1.75rem, 4vw, 2.75rem) 0 1.1rem;
}
.year:first-of-type { margin-top: 0; }
.year h3 {
  margin: 0; font-family: var(--mono); font-size: .82rem; font-weight: 500;
  color: var(--accent); letter-spacing: .06em;
}
.year::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.note {
  margin: 0 0 1.5rem;
  font-size: .78rem;
  color: var(--fg-dim);
  font-family: var(--mono);
}

.pubs {
  display: grid; gap: var(--gap);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr));
}

.pub {
  display: flex; flex-direction: column;
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform .28s var(--ease), border-color .28s var(--ease), box-shadow .28s var(--ease);
}
.pub:hover {
  transform: translateY(-3px);
  border-color: var(--accent-dim);
  box-shadow: 0 14px 40px -18px #000, 0 0 0 1px #ffffff08 inset;
}

/* contain, never cover: cropping a results figure destroys information */
.pub__media {
  position: relative;
  aspect-ratio: 16 / 10;
  background: var(--bg-sunk);
  border-bottom: 1px solid var(--line-soft);
  overflow: hidden;
}
.pub__media img, .pub__media video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: contain;
}
.pub__media video { opacity: 0; transition: opacity .4s var(--ease); }
.pub__media video[data-playing="true"] { opacity: 1; }
.pub__badge {
  position: absolute; top: .6rem; right: .6rem; z-index: 2;
  display: inline-flex; align-items: center; gap: .3rem;
  font-family: var(--mono); font-size: .66rem; letter-spacing: .04em;
  padding: .2rem .45rem; border-radius: 5px;
  background: #000000a6; color: #fff; backdrop-filter: blur(6px);
  border: 1px solid #ffffff1f;
}

.pub__body { padding: 1rem 1.1rem 1.15rem; display: flex; flex-direction: column; gap: .55rem; flex: 1; }
.pub__title {
  margin: 0; font-size: 1.02rem; line-height: 1.32;
  letter-spacing: -.017em; font-weight: 600;
}
.pub__authors { margin: 0; font-size: .845rem; color: var(--fg-dim); line-height: 1.5; }
.pub__authors .me { color: var(--fg); font-weight: 600; }
.pub__meta { margin: 0; font-size: .8rem; color: var(--fg-mid); }
.pub__venue { color: var(--accent); font-weight: 500; }
.pub__links { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: auto; padding-top: .35rem; }
.pub__links a {
  display: inline-flex; align-items: center; gap: .32rem;
  font-size: .765rem; color: var(--fg-mid);
  padding: .3rem .58rem; border-radius: 7px;
  border: 1px solid var(--line); background: var(--chip);
  transition: color .16s var(--ease), border-color .16s var(--ease), background .16s var(--ease);
}
.pub__links a:hover { color: var(--fg); border-color: var(--fg-dim); background: transparent; }
.pub__links svg { width: 12px; height: 12px; flex: 0 0 auto; }

/* ---------- simple stacked lists (patents, talks) ---------- */
.stack { display: grid; gap: .6rem; }
.item {
  padding: 1rem 1.1rem; border-radius: 12px;
  border: 1px solid var(--line); background: var(--bg-raise);
}
.item h4 { margin: 0 0 .3rem; font-size: .99rem; letter-spacing: -.015em; font-weight: 600; }
.item p { margin: 0; font-size: .855rem; color: var(--fg-mid); }
.item .who { color: var(--fg-dim); font-size: .82rem; }
.item .who .me { color: var(--fg); font-weight: 600; }
.item__links { display: flex; gap: .4rem; margin-top: .6rem; }

/* ---------- service pills ---------- */
.pills { display: flex; flex-wrap: wrap; gap: .4rem; }
.pill {
  font-family: var(--mono); font-size: .755rem; color: var(--fg-mid);
  padding: .34rem .6rem; border-radius: 7px;
  border: 1px solid var(--line); background: var(--chip);
}
.pill b { color: var(--accent); font-weight: 500; }

/* ---------- ethics ---------- */
.ethics {
  border-left: 2px solid var(--accent-dim);
  padding: .1rem 0 .1rem 1.25rem;
  max-width: 78ch;
}
.ethics p { margin: 0; color: var(--fg-mid); font-size: .93rem; }

/* ---------- contact ---------- */
.contact { display: flex; flex-wrap: wrap; gap: 2.5rem; }
.contact h4 {
  margin: 0 0 .35rem; font-family: var(--mono); font-size: .74rem;
  font-weight: 500; letter-spacing: .07em; color: var(--fg-dim);
  text-transform: uppercase;
}
.contact a { color: var(--fg); border-bottom: 1px solid var(--accent-dim); }
.contact a:hover { border-bottom-color: var(--accent); }

/* ---------- footer ---------- */
.foot {
  border-top: 1px solid var(--line-soft);
  padding-block: 2rem 3rem;
  display: flex; flex-wrap: wrap; gap: .75rem 1.5rem;
  align-items: center; justify-content: space-between;
  font-size: .8rem; color: var(--fg-dim);
}

/* ---------- reveal on scroll ---------- */
.reveal { opacity: 0; transform: translateY(10px); }
.reveal[data-shown="true"] {
  opacity: 1; transform: none;
  transition: opacity .5s var(--ease), transform .5s var(--ease);
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
  .reveal { opacity: 1; transform: none; }
  .pub:hover { transform: none; }
}

@media print {
  body::before, .nav, .toggle, .pub__media { display: none; }
  body { background: #fff; color: #000; font-size: 10pt; }
  .pubs { display: block; }
  .pub { border: 0; padding: 0 0 .5rem; break-inside: avoid; }
}
