/* ============================================================
   Rishi Madhok - personal site
   Brand-aligned with TerraByte: deep space dark + cyan glow
   ============================================================ */

:root {
  color-scheme: dark;
  --bg-deep: #02040a;
  --bg-main: #060b16;
  --panel: rgba(13, 24, 42, 0.45);
  --panel-hover: rgba(16, 30, 54, 0.65);
  --panel-border: rgba(90, 159, 255, 0.16);
  --panel-border-hover: rgba(101, 242, 255, 0.45);
  --text-primary: #f3f6ff;
  --text-secondary: #9fb0d4;
  --text-muted: #8593b6;
  --accent: #65f2ff;
  --accent-2: #2b8cff;
  --accent-glow: rgba(101, 242, 255, 0.35);
  --radius: 18px;
  --radius-lg: 26px;
  --maxw: 1120px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --shadow-lg: 0 30px 80px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; scroll-padding-top: 90px; }

body {
  font-family: 'Outfit', system-ui, sans-serif;
  background-color: var(--bg-deep);
  color: var(--text-primary);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; transition: color 0.25s var(--ease); }

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

img { max-width: 100%; display: block; }

::selection { background: var(--accent-glow); color: #fff; }

::-webkit-scrollbar { width: 9px; }
::-webkit-scrollbar-track { background: var(--bg-deep); }
::-webkit-scrollbar-thumb { background: rgba(90, 159, 255, 0.25); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-2); }

.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 28px; }

/* ---------- Animated backdrop ---------- */
.backdrop { position: fixed; inset: 0; z-index: -1; overflow: hidden; background: var(--bg-deep); }

.backdrop .stars {
  position: absolute; inset: -50%;
  background-image:
    radial-gradient(1px 1px at 20% 30%, rgba(255,255,255,0.8), transparent),
    radial-gradient(1px 1px at 60% 70%, rgba(255,255,255,0.6), transparent),
    radial-gradient(1.5px 1.5px at 80% 20%, rgba(160,210,255,0.7), transparent),
    radial-gradient(1px 1px at 40% 80%, rgba(255,255,255,0.5), transparent),
    radial-gradient(1px 1px at 90% 50%, rgba(255,255,255,0.6), transparent),
    radial-gradient(1.5px 1.5px at 10% 60%, rgba(160,210,255,0.5), transparent),
    radial-gradient(1px 1px at 75% 85%, rgba(255,255,255,0.5), transparent);
  background-size: 700px 700px;
  opacity: 0.5;
  animation: drift 180s linear infinite;
}

@keyframes drift {
  from { transform: translate3d(0,0,0); }
  to { transform: translate3d(-200px,-120px,0); }
}

.backdrop .glow { position: absolute; border-radius: 50%; filter: blur(120px); opacity: 0.5; }
.glow-1 { width: 620px; height: 620px; top: -200px; left: 50%; transform: translateX(-50%);
  background: radial-gradient(circle, rgba(43,140,255,0.45), transparent 70%); }
.glow-2 { width: 520px; height: 520px; bottom: -180px; right: -120px;
  background: radial-gradient(circle, rgba(101,242,255,0.22), transparent 70%); }

.backdrop .grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(90,159,255,0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(90,159,255,0.05) 1px, transparent 1px);
  background-size: 60px 60px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 30%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 30%, transparent 75%);
}

/* ---------- Shared bits ---------- */
.highlight { color: var(--accent); font-weight: 600; text-shadow: 0 0 24px var(--accent-glow); }

.link-accent { color: var(--accent); font-weight: 500; }
.link-accent:hover { color: #fff; text-shadow: 0 0 18px var(--accent-glow); }

.eyebrow, .section-eyebrow {
  font-size: 0.78rem; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--accent); font-weight: 600;
  display: inline-flex; align-items: center; gap: 9px;
}
.section-eyebrow { color: var(--text-muted); margin-bottom: 14px; }

.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 0 0 var(--accent-glow); animation: pulse 2.4s infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(101,242,255,0.5); }
  70% { box-shadow: 0 0 0 12px rgba(101,242,255,0); }
  100% { box-shadow: 0 0 0 0 rgba(101,242,255,0); }
}

.section-title {
  font-size: clamp(1.7rem, 3.4vw, 2.5rem); font-weight: 600; line-height: 1.15;
  letter-spacing: -0.02em; margin-bottom: 36px;
}
.subsection-title {
  font-size: 1.25rem; font-weight: 600; margin: 56px 0 24px;
  letter-spacing: -0.01em;
}

.section { padding: 96px 0; position: relative; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 13px 24px; border-radius: 999px; font-weight: 600; font-size: 0.96rem;
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease), background 0.25s var(--ease);
}
.btn svg { transition: transform 0.25s var(--ease); }
.btn-primary {
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  color: #02040a; box-shadow: 0 10px 30px rgba(43,140,255,0.35);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 16px 40px rgba(101,242,255,0.45); }
.btn-primary:hover svg { transform: translate(2px,-2px); }
.btn-ghost {
  background: rgba(255,255,255,0.04); color: var(--text-primary);
  border: 1px solid var(--panel-border);
}
.btn-ghost:hover { border-color: var(--panel-border-hover); background: rgba(255,255,255,0.07); transform: translateY(-2px); }

/* ---------- Header ---------- */
.site-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  padding: 18px 0; transition: padding 0.3s var(--ease), background 0.3s var(--ease), border-color 0.3s var(--ease);
  border-bottom: 1px solid transparent;
}
.site-header.scrolled {
  padding: 12px 0; background: rgba(4, 8, 18, 0.8);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--panel-border);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; }

.brand { display: inline-flex; align-items: center; gap: 12px; font-weight: 600; }
.brand-mark {
  display: inline-grid; place-items: center; width: 38px; height: 38px;
  border-radius: 11px; font-size: 0.85rem; font-weight: 700; letter-spacing: 0.02em;
  color: #02040a; background: linear-gradient(120deg, var(--accent), var(--accent-2));
  box-shadow: 0 6px 18px rgba(43,140,255,0.4);
}
.brand-mark.small { width: 32px; height: 32px; font-size: 0.75rem; }
.brand-name { font-size: 1.02rem; letter-spacing: -0.01em; }

.nav { display: flex; align-items: center; gap: 30px; }
.nav a { font-size: 0.95rem; color: var(--text-secondary); font-weight: 500; }
.nav a:hover { color: var(--text-primary); }
.nav .nav-cta {
  padding: 9px 18px; border-radius: 999px; border: 1px solid var(--panel-border);
  color: var(--accent);
}
.nav .nav-cta:hover { border-color: var(--panel-border-hover); background: rgba(101,242,255,0.08); color: #fff; }

.nav-toggle { display: none; flex-direction: column; gap: 5px; padding: 8px; }
.nav-toggle span { width: 22px; height: 2px; background: var(--text-primary); border-radius: 2px; transition: 0.25s var(--ease); }

.mobile-nav {
  display: none; flex-direction: column; gap: 4px; padding: 0 28px;
  max-height: 0; overflow: hidden; transition: max-height 0.35s var(--ease), padding 0.35s var(--ease);
  background: rgba(4, 8, 18, 0.95); backdrop-filter: blur(18px);
}
.mobile-nav.open { max-height: 320px; padding: 12px 28px 22px; border-bottom: 1px solid var(--panel-border); }
.mobile-nav a { padding: 12px 0; color: var(--text-secondary); border-bottom: 1px solid rgba(255,255,255,0.05); }
.mobile-nav a:hover { color: var(--accent); }

/* ---------- Hero ---------- */
.hero { padding: 168px 0 96px; }
.hero-inner { display: grid; grid-template-columns: 1.35fr 0.9fr; gap: 56px; align-items: center; }

.hero-title {
  font-size: clamp(2.8rem, 7vw, 4.6rem); font-weight: 700; line-height: 1.02;
  letter-spacing: -0.03em; margin: 18px 0 22px;
  background: linear-gradient(150deg, #ffffff 30%, #9fc7ff 75%, var(--accent));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.hero-lede { font-size: clamp(1.1rem, 2vw, 1.35rem); color: var(--text-primary); max-width: 30ch; margin-bottom: 16px; }
.hero-sub { font-size: 1.02rem; color: var(--text-secondary); max-width: 46ch; margin-bottom: 30px; }

.hero-actions { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 32px; }
.hero-actions.center { justify-content: center; }

.hero-links { list-style: none; display: flex; gap: 14px; }
.hero-links a, .hero-links button {
  display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border-radius: 12px;
  background: var(--panel); border: 1px solid var(--panel-border); color: var(--text-secondary);
  transition: 0.25s var(--ease);
}
.hero-links svg { width: 19px; height: 19px; }
.hero-links a:hover, .hero-links button:hover { color: var(--accent); border-color: var(--panel-border-hover); transform: translateY(-3px); background: var(--panel-hover); }

/* portrait */
.hero-portrait { position: relative; justify-self: center; }
.portrait-ring {
  position: relative; width: clamp(220px, 26vw, 320px); aspect-ratio: 1; border-radius: 50%;
  padding: 6px; background: conic-gradient(from 180deg, var(--accent), var(--accent-2), transparent, var(--accent));
  box-shadow: 0 0 60px rgba(43,140,255,0.35);
  animation: spinRing 18s linear infinite;
}
@keyframes spinRing { to { transform: rotate(360deg); } }
.portrait-ring img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover;
  animation: spinRing 18s linear infinite reverse; background: var(--bg-main); }
.portrait-badge {
  position: absolute; bottom: 6%; right: 2%; width: 64px; height: 64px; border-radius: 16px;
  display: grid; place-items: center; padding: 12px;
  background: rgba(4,8,18,0.85); border: 1px solid var(--panel-border-hover);
  backdrop-filter: blur(10px); box-shadow: var(--shadow-lg);
}
.portrait-badge img { width: 100%; height: 100%; object-fit: contain; }

/* ---------- About ---------- */
.about-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 44px; align-items: start; }
.about-lead { font-size: 1.3rem; line-height: 1.55; color: var(--text-primary); margin-bottom: 22px; letter-spacing: -0.01em; }
.about-body p { color: var(--text-secondary); font-size: 1.05rem; }

.about-side { display: grid; gap: 18px; }
.side-card {
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius);
  padding: 24px; backdrop-filter: blur(12px);
}
.side-card h3 { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.14em; color: var(--accent); margin-bottom: 14px; }
.side-subhead { margin-top: 22px; }
.side-list { list-style: none; display: grid; gap: 12px; }
.side-list li { display: flex; flex-direction: column; font-size: 1rem; color: var(--text-primary); }
.side-list li span { font-size: 0.78rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; }

/* tag rows */
.tag-row { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; }
.tag-row li {
  font-size: 0.85rem; color: var(--text-secondary); padding: 6px 13px; border-radius: 999px;
  background: rgba(255,255,255,0.04); border: 1px solid var(--panel-border);
}
.tag-row li small { color: var(--text-muted); }

/* ---------- Timeline ---------- */
.timeline { list-style: none; position: relative; }
.timeline::before {
  content: ""; position: absolute; left: 27px; top: 8px; bottom: 8px; width: 2px;
  background: linear-gradient(180deg, var(--accent), rgba(90,159,255,0.1));
}
.timeline-item { position: relative; display: grid; grid-template-columns: 56px 1fr; gap: 22px; padding-bottom: 38px; }
.timeline-item:last-child { padding-bottom: 0; }
.tl-logo {
  position: relative; z-index: 2; width: 56px; height: 56px; border-radius: 14px;
  display: grid; place-items: center; padding: 11px;
  background: rgba(4,8,18,0.9); border: 1px solid var(--panel-border);
}
.tl-logo img { width: 100%; height: 100%; object-fit: contain; border-radius: 4px; }
.tl-body {
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius);
  padding: 22px 24px; transition: 0.3s var(--ease); backdrop-filter: blur(12px);
}
.tl-body:hover { border-color: var(--panel-border-hover); background: var(--panel-hover); transform: translateY(-2px); }
.tl-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 16px; }
.tl-head h3 { font-size: 1.18rem; font-weight: 600; letter-spacing: -0.01em; }
.tl-time { font-family: 'Fira Code', monospace; font-size: 0.8rem; color: var(--accent); white-space: nowrap; }
.tl-org { color: var(--text-secondary); font-weight: 500; margin: 2px 0 10px; }
.tl-desc { color: var(--text-secondary); font-size: 0.97rem; }

/* role progression within one company */
.role-list { list-style: none; display: grid; gap: 16px; margin-top: 14px; padding-top: 16px; border-top: 1px solid var(--panel-border); }
.role { position: relative; padding-left: 18px; }
.role::before {
  content: ""; position: absolute; left: 0; top: 9px; width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 10px var(--accent-glow);
}
.role:not(:first-child)::before { background: var(--text-muted); box-shadow: none; }
.role-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 14px; }
.role-head h4 { font-size: 1.02rem; font-weight: 600; letter-spacing: -0.01em; }
.role-time { font-family: 'Fira Code', monospace; font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; }
.role-points { margin: 9px 0 0; padding-left: 18px; display: grid; gap: 7px; }
.role-points li { color: var(--text-secondary); font-size: 0.93rem; }
.role-points strong { color: var(--text-primary); font-weight: 600; }
.role-desc { color: var(--text-secondary); font-size: 0.92rem; margin-top: 5px; }

/* ---------- Work ---------- */
.work-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.work-card {
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius-lg);
  padding: 30px; display: flex; flex-direction: column; gap: 16px;
  transition: 0.3s var(--ease); backdrop-filter: blur(12px); position: relative; overflow: hidden;
}
.work-card::before {
  content: ""; position: absolute; inset: 0; opacity: 0; transition: opacity 0.4s var(--ease);
  background: radial-gradient(circle at 100% 0%, rgba(101,242,255,0.1), transparent 55%);
  pointer-events: none;
}
.work-card:hover { border-color: var(--panel-border-hover); transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.work-card:hover::before { opacity: 1; }
.work-kicker { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.14em; color: var(--accent); font-weight: 600; }
.work-card-top h3 { font-size: 1.4rem; font-weight: 600; margin-top: 8px; letter-spacing: -0.01em; }
.work-card p { color: var(--text-secondary); font-size: 0.98rem; }
.work-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; }
.work-tags span {
  font-size: 0.78rem; color: var(--text-secondary); padding: 5px 11px; border-radius: 999px;
  background: rgba(101,242,255,0.06); border: 1px solid var(--panel-border);
}
.work-links { display: flex; gap: 18px; align-items: center; }
.work-link { position: relative; z-index: 1; display: inline-flex; align-items: center; gap: 6px; color: var(--accent); font-weight: 600; font-size: 0.95rem; }
.work-link:hover { color: #fff; }
.work-link.subtle { color: var(--text-secondary); font-weight: 500; }
.work-link.subtle:hover { color: var(--accent); }

/* research */
.research-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.research-card {
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius);
  padding: 24px; transition: 0.3s var(--ease); backdrop-filter: blur(12px);
}
.research-card:hover { border-color: var(--panel-border-hover); transform: translateY(-3px); }
.research-card h4 { font-size: 1.08rem; font-weight: 600; margin-bottom: 6px; letter-spacing: -0.01em; }
.research-advisor { font-size: 0.82rem; color: var(--accent); margin-bottom: 12px; font-family: 'Fira Code', monospace; }
.research-card p { color: var(--text-secondary); font-size: 0.92rem; }

/* ---------- Publications ---------- */
.pub-stats {
  display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-bottom: 40px;
}
.pub-stats .stat {
  display: flex; flex-direction: column; align-items: center; padding: 16px 26px;
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius);
  backdrop-filter: blur(12px); min-width: 110px;
}
.stat-num { font-size: 1.7rem; font-weight: 700; color: var(--accent); line-height: 1; }
.stat-label { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); margin-top: 7px; }
.stat-link { margin-left: auto; color: var(--accent); font-weight: 600; font-size: 0.95rem; }
.stat-link:hover { color: #fff; }

.pub-group-title {
  font-family: 'Fira Code', monospace; font-size: 0.82rem; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-muted); margin: 36px 0 16px;
  padding-bottom: 10px; border-bottom: 1px solid var(--panel-border);
}
.pub-list { list-style: none; display: grid; gap: 4px; }
.pub { padding: 16px 18px; border-radius: 14px; border: 1px solid transparent; transition: 0.25s var(--ease); }
.pub:hover { background: var(--panel); border-color: var(--panel-border); }
.pub-title { display: inline-block; font-size: 1.05rem; font-weight: 600; color: var(--text-primary); letter-spacing: -0.01em; }
a.pub-title:hover { color: var(--accent); }
.pub-authors { color: var(--text-secondary); font-size: 0.92rem; margin-top: 4px; }
.pub-authors u { color: var(--text-primary); text-decoration-color: var(--accent); }
.pub-venue { color: var(--text-muted); font-size: 0.85rem; font-family: 'Fira Code', monospace; margin-top: 3px; }
.pub-foot { margin-top: 26px; }

/* ---------- Split (skills + education) ---------- */
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 56px; align-items: start; }
.skill-groups { display: grid; gap: 24px; }
.skill-group h4 { font-size: 0.95rem; font-weight: 600; margin-bottom: 12px; color: var(--text-primary); }

.edu-list { display: grid; gap: 18px; }
.edu-item {
  display: grid; grid-template-columns: 56px 1fr; gap: 18px; align-items: center;
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius);
  padding: 20px 22px; transition: 0.3s var(--ease); backdrop-filter: blur(12px);
}
.edu-item:hover { border-color: var(--panel-border-hover); transform: translateY(-2px); }
.edu-item h3 { font-size: 1.12rem; font-weight: 600; }
.edu-degree { color: var(--text-secondary); font-size: 0.95rem; margin-top: 2px; }
.edu-meta { color: var(--text-muted); font-size: 0.82rem; font-family: 'Fira Code', monospace; margin-top: 5px; }

/* ---------- Contact ---------- */
.contact { text-align: center; }
.contact-inner { max-width: 640px; margin: 0 auto; }
.contact-title { font-size: clamp(1.8rem, 4vw, 2.8rem); font-weight: 600; letter-spacing: -0.02em; margin: 14px 0 16px; line-height: 1.15; }
.contact-sub { color: var(--text-secondary); font-size: 1.08rem; margin-bottom: 32px; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--panel-border); padding: 32px 0; }
.footer-inner { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.footer-inner p { color: var(--text-muted); font-size: 0.9rem; }
.footer-links { list-style: none; display: flex; gap: 20px; margin-left: auto; }
.footer-links a, .footer-links button { color: var(--text-secondary); font-size: 0.9rem; }
.footer-links a:hover, .footer-links button:hover { color: var(--accent); }

/* ---------- Reveal animation ----------
   Gated on the .js class (set by an inline script in <head>) so that if JS is
   disabled, blocked, or fails to load, all content stays visible by default. */
.js [data-reveal] { opacity: 0; transform: translateY(24px); transition: opacity 0.7s var(--ease), transform 0.7s var(--ease); }
.js [data-reveal].in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
  [data-reveal] { opacity: 1 !important; transform: none !important; }
  html { scroll-behavior: auto; }
}

/* ---------- Responsive ---------- */
@media (max-width: 920px) {
  .hero-inner { grid-template-columns: 1fr; gap: 44px; text-align: center; }
  .hero-content { order: 2; }
  .hero-portrait { order: 1; }
  .hero-lede, .hero-sub { max-width: none; margin-left: auto; margin-right: auto; }
  .hero-actions, .hero-links { justify-content: center; }
  .about-grid { grid-template-columns: 1fr; gap: 32px; }
  .work-grid { grid-template-columns: 1fr; }
  .research-grid { grid-template-columns: 1fr; }
  .split { grid-template-columns: 1fr; gap: 44px; }
}

@media (max-width: 720px) {
  .nav { display: none; }
  .nav-toggle { display: flex; }
  .mobile-nav { display: flex; }
  .section { padding: 72px 0; }
  .hero { padding: 132px 0 72px; }
  .pub-stats .stat { flex: 1; min-width: 90px; padding: 14px; }
  .stat-link { margin-left: 0; flex-basis: 100%; text-align: center; margin-top: 8px; }
  .footer-links { margin-left: 0; flex-basis: 100%; justify-content: flex-start; }
}

@media (max-width: 420px) {
  .container { padding: 0 20px; }
  .timeline-item { grid-template-columns: 44px 1fr; gap: 14px; }
  .timeline::before { left: 21px; }
  .tl-logo { width: 44px; height: 44px; padding: 8px; }
  .pub-stats .stat { min-width: 0; }
}
