/* ==================================================================
   raviffg.github.io — clean academic / researcher layout
   light theme, media-left rows, inline disclosure, live canvases
   ================================================================== */

:root {
  --bg: #ffffff;
  --bg-soft: #fafafa;
  --bg-tint: #f8fafc;
  --ink: #111827;
  --ink-2: #374151;
  --ink-3: #6b7280;
  --ink-4: #9ca3af;
  --rule: #e5e7eb;
  --rule-2: #eef1f4;
  --link: #0056b3;
  --link-hover: #003f80;
  --accent: #0b6bcb;
  --chip: #eef4fb;
  --shadow: 0 1px 2px rgba(17, 24, 39, 0.04), 0 8px 24px -18px rgba(17, 24, 39, 0.25);
  --shadow-lift: 0 2px 6px rgba(17, 24, 39, 0.06), 0 18px 40px -24px rgba(17, 24, 39, 0.35);
  --mono: ui-monospace, "JetBrains Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --serif: "Source Serif 4", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --max: 940px;
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink-2);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.64;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); text-decoration: underline; text-underline-offset: 2px; }

::selection { background: #cfe4ff; color: #06213f; }

/* ---------------- sticky nav ---------------- */

.nav {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: saturate(160%) blur(10px);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--rule);
}

.nav-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 11px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.nav-name {
  font-weight: 650;
  font-size: 15px;
  letter-spacing: -0.012em;
  color: var(--ink);
  white-space: nowrap;
}

.nav-name:hover { text-decoration: none; color: var(--ink); }

.nav-links {
  display: flex;
  gap: 20px;
  font-size: 13.5px;
  color: var(--ink-3);
}

.nav-links a { color: var(--ink-3); border-bottom: 1px solid transparent; padding-bottom: 2px; }
.nav-links a:hover { color: var(--ink); text-decoration: none; border-bottom-color: var(--ink); }
.nav-links a.active { color: var(--ink); border-bottom-color: var(--accent); }

main {
  max-width: var(--max);
  margin: 0 auto;
  padding: 44px 20px 96px;
}

/* ---------------- masthead ---------------- */

.masthead { display: block; }

h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(30px, 4.4vw, 40px);
  line-height: 1.12;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
}

h1 .alt { font-family: var(--sans); font-size: 0.5em; font-weight: 400; color: var(--ink-3); letter-spacing: 0; }

.tagline {
  margin: 8px 0 0;
  font-size: 15.5px;
  color: var(--ink-3);
}

.contact {
  margin: 14px 0 0;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.01em;
  color: var(--ink-3);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
}

.contact .sep { color: var(--ink-4); }

.bio {
  margin: 22px 0 0;
  max-width: 72ch;
  font-size: 16.2px;
  color: var(--ink-2);
}

.bio + .bio { margin-top: 12px; }

/* ---------------- section headings ---------------- */

section { margin-top: 52px; }

.sec-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 8px;
  margin-bottom: 6px;
}

h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.012em;
  color: var(--ink);
}

.sec-note {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink-4);
  white-space: nowrap;
}

.sec-lede {
  margin: 12px 0 0;
  font-size: 15px;
  color: var(--ink-3);
  max-width: 74ch;
}

/* ---------------- research / project rows ---------------- */

.rows { margin-top: 6px; }

.rows > .row {
  display: grid;
  grid-template-columns: 264px 1fr;
  gap: 26px;
  align-items: start;
  padding: 26px 0;
  border-bottom: 1px solid var(--rule-2);
}

.rows > .row:last-child { border-bottom: 0; }

.thumb {
  position: relative;
  aspect-ratio: 4 / 3;
  border: 1px solid var(--rule);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-tint);
  box-shadow: var(--shadow);
  transition: box-shadow 0.28s ease, transform 0.28s ease, border-color 0.28s ease;
}

.rows > .row:hover .thumb {
  box-shadow: var(--shadow-lift);
  transform: translateY(-2px);
  border-color: #d7e0ea;
}

.thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #fff;
  transition: transform 0.6s cubic-bezier(0.2, 0.7, 0.2, 1), filter 0.3s;
}

.rows > .row:hover .thumb img { transform: scale(1.04); }

.thumb canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
}

.thumb.is-anim canvas { opacity: 1; }
.thumb.is-anim img { opacity: 0.001; }

.anim-toggle {
  position: absolute;
  left: 8px;
  bottom: 8px;
  z-index: 3;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fff;
  background: rgba(17, 24, 39, 0.72);
  border: 0;
  border-radius: 999px;
  padding: 3px 8px 3px 6px;
  cursor: pointer;
  opacity: 0.9;
  transition: background 0.2s, opacity 0.2s;
}

.anim-toggle:hover { background: rgba(17, 24, 39, 0.9); }
.thumb.is-anim .anim-toggle { background: rgba(11, 107, 203, 0.9); }

.body h3 {
  margin: 0;
  font-size: 17.5px;
  line-height: 1.34;
  font-weight: 650;
  letter-spacing: -0.012em;
  color: var(--ink);
}

.authors {
  margin: 6px 0 0;
  font-size: 14px;
  color: var(--ink-3);
}

.authors b { color: var(--ink); font-weight: 650; }

.meta {
  margin: 8px 0 0;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--ink-3);
}

.badge {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: #0b4a86;
  background: var(--chip);
  border: 1px solid #dbe8f6;
  border-radius: 4px;
  padding: 1px 6px;
}

.venue { font-size: 13.5px; color: var(--ink-2); font-weight: 500; }

.dim { color: var(--ink-4); }

.metric {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink-4);
}

.summary { margin: 9px 0 0; font-size: 14.6px; line-height: 1.6; color: var(--ink-2); }

.pills { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }

.pill {
  appearance: none;
  font-family: var(--sans);
  font-size: 12.4px;
  font-weight: 500;
  line-height: 1;
  color: var(--ink-2);
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 6px 11px;
  cursor: pointer;
  transition: background 0.16s, border-color 0.16s, color 0.16s, box-shadow 0.16s;
  white-space: nowrap;
}

.pill:hover {
  background: #f6f9fd;
  border-color: #c3d7ee;
  color: var(--link);
  text-decoration: none;
  box-shadow: 0 1px 2px rgba(11, 107, 203, 0.12);
}

.pill .caret {
  display: inline-block;
  width: 0;
  height: 0;
  margin-left: 6px;
  vertical-align: middle;
  border-left: 3.5px solid transparent;
  border-right: 3.5px solid transparent;
  border-top: 4px solid currentColor;
  opacity: 0.5;
  transform: translateY(-1px);
  transition: transform 0.2s ease;
}
.pill[aria-expanded="true"] { background: #f1f7fe; border-color: #b9d3ee; color: var(--link); }
.pill[aria-expanded="true"] .caret { transform: translateY(1px) rotate(180deg); opacity: 0.8; }
.pill.solid { background: var(--accent); border-color: var(--accent); color: #fff; }
.pill.solid:hover { background: #095ab0; color: #fff; }

/* inline disclosure */

.drop {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.3s cubic-bezier(0.25, 0.7, 0.3, 1), opacity 0.24s;
  opacity: 0;
}

.drop.open { grid-template-rows: 1fr; opacity: 1; }

.drop-inner { overflow: hidden; min-height: 0; }

.drop-inner > * { margin: 10px 0 0; }

.abs {
  font-size: 13.9px;
  line-height: 1.62;
  color: var(--ink-2);
  border-left: 2px solid #dbe8f6;
  padding-left: 11px;
}

.bib {
  font-family: var(--mono);
  font-size: 11.6px;
  line-height: 1.55;
  color: #24313f;
  background: var(--bg-tint);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 11px 12px;
  overflow-x: auto;
  white-space: pre;
}

/* ---------------- workbench (light lab) ---------------- */

.wb {
  margin-top: 16px;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: #fff;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.wb-tabs { display: grid; grid-template-columns: repeat(4, 1fr); border-bottom: 1px solid var(--rule); }

.mode {
  appearance: none;
  background: #fff;
  border: 0;
  border-right: 1px solid var(--rule-2);
  border-bottom: 2px solid transparent;
  padding: 11px 13px 10px;
  text-align: left;
  font: inherit;
  cursor: pointer;
  color: var(--ink-3);
  transition: background 0.16s, color 0.16s, border-color 0.16s;
}

.mode:last-child { border-right: 0; }
.mode:hover { background: #f7fafd; }

.mode .m-id { font-family: var(--mono); font-size: 10px; color: var(--ink-4); margin-right: 6px; }
.mode .m-tx { font-size: 12.6px; line-height: 1.32; font-weight: 550; }

.mode[aria-selected="true"] {
  background: #f4f9ff;
  border-bottom-color: var(--accent);
  color: var(--ink);
}

.mode[aria-selected="true"] .m-id { color: var(--accent); }

.wb-body { display: grid; grid-template-columns: 1fr 252px; }

.stage {
  position: relative;
  height: 500px;
  background: var(--bg-tint);
  border-right: 1px solid var(--rule);
  overflow: hidden;
}

.stage canvas#gl { position: absolute; inset: 0; display: block; width: 100%; height: 100%; cursor: grab; }
.stage canvas#gl:active { cursor: grabbing; }

.hud {
  position: absolute;
  z-index: 3;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-3);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 7px 10px 8px;
  pointer-events: none;
  box-shadow: 0 1px 2px rgba(17, 24, 39, 0.04);
}

.hud-tl { top: 12px; left: 12px; }
.hud-tr { top: 12px; right: 12px; text-align: right; min-width: 118px; }
.hud-bl { bottom: 96px; left: 12px; }
.hud-br { bottom: 96px; right: 12px; width: 168px; }

.hud-k { font-size: 9px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-4); }
.hud-v { font-size: 12px; color: var(--ink); margin-top: 1px; }
.hud-sub { font-size: 9.5px; color: var(--accent); margin-top: 2px; letter-spacing: 0.04em; text-transform: uppercase; }
.hud-row { display: flex; gap: 8px; justify-content: space-between; align-items: baseline; }
.hud-row b { color: var(--ink); font-weight: 500; font-variant-numeric: tabular-nums; }
.hud-field b { color: #b45309; }
.hud-bl b { color: var(--ink); font-variant-numeric: tabular-nums; }

.legend-bar { height: 7px; border: 1px solid var(--rule); border-radius: 3px; background: linear-gradient(to right, #000, #fff); }
.legend-ticks { display: flex; justify-content: space-between; font-size: 9.5px; color: var(--ink-3); margin-top: 3px; font-variant-numeric: tabular-nums; }
.legend-cap { margin-top: 3px; font-size: 9.5px; line-height: 1.35; color: var(--ink-3); }
.legend-cap b { color: var(--ink); font-weight: 500; }

.osc {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 84px;
  background: rgba(255, 255, 255, 0.95);
  border-top: 1px solid var(--rule);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.osc-head {
  display: flex;
  align-items: center;
  gap: 13px;
  height: 23px;
  padding: 0 12px;
  border-bottom: 1px solid var(--rule-2);
  font-family: var(--mono);
  font-size: 9.6px;
  color: var(--ink-4);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.osc-live { display: flex; align-items: center; gap: 6px; color: var(--ink-3); }
.osc-live i {
  width: 6px; height: 6px; border-radius: 50%;
  background: #10b981; box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

.osc-ch b { font-variant-numeric: tabular-nums; font-weight: 500; color: var(--ink-2); }
.osc-ch em { font-style: normal; font-size: 8.6px; color: var(--ink-4); margin-left: 3px; }
.ch-iq b { color: #0b6bcb; }
.ch-sv b { color: #b45309; }
.ch-dt b { color: #047857; }
.osc-hint { margin-left: auto; font-size: 9px; text-transform: none; letter-spacing: 0; }

.osc canvas { display: block; width: 100%; height: calc(100% - 23px); }

.side {
  padding: 14px 14px 12px;
  background: #fff;
  display: flex;
  flex-direction: column;
}

.side h3 {
  margin: 0 0 9px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-4);
  padding-bottom: 5px;
  border-bottom: 1px solid var(--rule-2);
}

.ctl[hidden] { display: none; }

label.row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin: 9px 0 2px;
  font-size: 12.2px;
  color: var(--ink-3);
}

label.row b { font-size: 12px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }

.readrow {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 10px 0 2px;
  padding: 6px 8px;
  border: 1px solid #f0e2cf;
  background: #fdf8f1;
  border-radius: 5px;
  font-size: 11.4px;
  color: #92672a;
}

.readrow b { color: #b45309; font-weight: 650; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 16px;
  background: transparent;
  cursor: pointer;
  margin: 0;
}

input[type="range"]::-webkit-slider-runnable-track { height: 3px; border-radius: 2px; background: #dbe3ec; }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 13px; height: 13px; margin-top: -5px;
  border-radius: 50%;
  background: #fff;
  border: 1.5px solid var(--accent);
  box-shadow: 0 1px 3px rgba(17, 24, 39, 0.18);
}
input[type="range"]::-moz-range-track { height: 3px; background: #dbe3ec; }
input[type="range"]::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 1.5px solid var(--accent); }

label.chk {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 9px 0 2px;
  font-size: 12.2px;
  color: var(--ink-3);
  cursor: pointer;
}

input[type="checkbox"] { width: 13px; height: 13px; margin: 0; accent-color: var(--accent); cursor: pointer; }

.note { margin: 11px 0 0; font-size: 11.4px; line-height: 1.5; color: var(--ink-4); }

.presets { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 8px 0 2px; }
.presets .pill { padding: 5px 8px; font-size: 11.6px; justify-content: center; }

/* ---------------- publications ---------------- */

ol.pubs { list-style: none; margin: 8px 0 0; padding: 0; }

ol.pubs li {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--rule-2);
}

ol.pubs li:last-child { border-bottom: 0; }
ol.pubs .ref { font-family: var(--mono); font-size: 11.5px; color: var(--ink-4); padding-top: 2px; }
ol.pubs .cite { font-size: 14.6px; line-height: 1.58; color: var(--ink-2); }
ol.pubs .cite em { font-style: italic; color: var(--ink); }
ol.pubs .pills { margin-top: 8px; }

/* ---------------- playgrounds ---------------- */

.play-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 14px; }

.play {
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.play header {
  display: flex;
  align-items: baseline;
  gap: 7px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--rule-2);
}

.play h3 { margin: 0; font-size: 12.4px; font-weight: 600; color: var(--ink); }
.play .w-id { font-family: var(--mono); font-size: 10px; color: var(--ink-4); }
.play .w-status { margin-left: auto; font-family: var(--mono); font-size: 10px; color: var(--ink-4); white-space: nowrap; }
.play canvas { display: block; width: 100%; height: 190px; background: var(--bg-tint); touch-action: none; }
.play footer { display: flex; align-items: center; gap: 7px; padding: 7px 10px; border-top: 1px solid var(--rule-2); flex-wrap: wrap; }
.w-hint { font-size: 10.6px; color: var(--ink-4); line-height: 1.3; }
.w-slider { display: flex; align-items: center; gap: 6px; margin-left: auto; font-size: 10.6px; color: var(--ink-4); }
.w-slider input[type="range"] { width: 68px; }

/* ---------------- footer ---------------- */

.foot {
  margin-top: 56px;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
  display: flex;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--ink-4);
}

/* ---------------- reveal on scroll ---------------- */

.reveal { opacity: 0; transform: translateY(10px); }

.reveal.in {
  opacity: 1;
  transform: none;
  transition: opacity 0.55s ease, transform 0.55s cubic-bezier(0.2, 0.7, 0.2, 1);
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; }
  .reveal.in { transition: none; }
  .thumb img, .rows > .row:hover .thumb img { transition: none; transform: none; }
  .osc-live i { animation: none; }
}

/* ---------------- responsive ---------------- */

@media (max-width: 860px) {
  .rows > .row { grid-template-columns: 1fr; gap: 14px; }
  .thumb { max-width: 100%; }
  .wb-body { grid-template-columns: 1fr; }
  .stage { border-right: 0; border-bottom: 1px solid var(--rule); height: 430px; }
  .play-grid { grid-template-columns: 1fr; }
  .hud-tr, .hud-br { display: none; }
  .wb-tabs { grid-template-columns: 1fr 1fr; }
  .mode:nth-child(2) { border-right: 0; }
  .mode:nth-child(1), .mode:nth-child(2) { border-bottom: 1px solid var(--rule-2); }
}

@media (max-width: 640px) {
  main { padding: 28px 16px 64px; }
  .nav-links { gap: 13px; font-size: 12.5px; }
  .nav-name { font-size: 14px; }
  .stage { height: 380px; }
  .mode .m-tx { font-size: 11.6px; }
}
