/* ==========================================================================
   COSMIC DEPTH — design system for rishabh01solanki.github.io
   One file, no build step. Layers: starfield canvas (z:0) → nebula (z:1)
   → content (z:2) → nav (z:10).
   ========================================================================== */

/* ---- Tokens ------------------------------------------------------------ */
:root {
  --bg-space: #050510;
  --surface: rgba(255, 255, 255, 0.05);
  --surface-border: rgba(255, 255, 255, 0.10);
  --surface-solid: #0d0f23;
  --text-hi: #f1f3fa;
  --text-body: #c3c9da;
  --text-muted: #8a91a8;
  --accent: #818cf8;
  --accent-hot: #a78bfa;
  --accent-faint: rgba(129, 140, 248, 0.14);
  --glow: 0 0 24px rgba(129, 140, 248, 0.25);
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Instrument Sans", "Helvetica Neue", Arial, sans-serif;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --container: 1100px;
  --prose: 46rem;
}

/* ---- Reset & base ------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg-space);
  color: var(--text-body);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img, video, canvas { max-width: 100%; }

::selection { background: rgba(129, 140, 248, 0.35); color: var(--text-hi); }

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.25s ease, text-shadow 0.25s ease;
}
a:hover { color: var(--accent-hot); text-shadow: 0 0 14px rgba(167, 139, 250, 0.45); }

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

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--text-hi);
  line-height: 1.15;
  letter-spacing: 0.005em;
}
h4, h5, h6 { color: var(--text-hi); line-height: 1.35; }

strong, b { color: var(--text-hi); font-weight: 600; }

hr {
  border: none;
  border-top: 1px solid var(--surface-border);
  margin: 3rem 0;
}

figcaption { color: var(--text-muted); }

/* ---- Atmosphere: starfield, nebula, grain ------------------------------ */
#starfield {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.nebula {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(42rem 42rem at 15% 80%, rgba(76, 29, 149, 0.16), transparent 70%),
    radial-gradient(50rem 38rem at 85% 18%, rgba(49, 46, 129, 0.20), transparent 70%),
    radial-gradient(60rem 44rem at 50% 118%, rgba(8, 47, 73, 0.14), transparent 70%);
}

/* film grain — tiny inline SVG noise, fixed, nearly invisible but felt */
.nebula::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='0.6'/%3E%3C/svg%3E");
}

main { position: relative; z-index: 2; }

/* ---- Navigation -------------------------------------------------------- */
.site-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem clamp(1.25rem, 4vw, 3rem);
  background: rgba(5, 5, 16, 0.55);
  border-bottom: 1px solid var(--surface-border);
}
@supports (backdrop-filter: blur(1px)) {
  .site-nav { backdrop-filter: blur(14px) saturate(1.2); }
}

.nav-brand {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-hi);
  white-space: nowrap;
}
.nav-brand .star { color: var(--accent); }
.nav-brand:hover { text-shadow: var(--glow); }

.nav-links {
  display: flex;
  align-items: center;
  gap: clamp(0.6rem, 1.8vw, 1.6rem);
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-links a {
  color: var(--text-muted);
  font-size: 0.92rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.nav-links a:hover { color: var(--text-hi); text-shadow: none; }
.nav-links a.active { color: var(--accent); }

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--surface-border);
  border-radius: 8px;
  color: var(--text-hi);
  font: inherit;
  padding: 0.3rem 0.7rem;
  cursor: pointer;
}

@media (max-width: 860px) {
  .nav-toggle { display: block; }
  .nav-links {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    padding: 0.5rem 1.25rem 1rem;
    background: rgba(8, 9, 24, 0.96);
    border-bottom: 1px solid var(--surface-border);
    display: none;
  }
  .nav-links.open { display: flex; }
  .nav-links li { width: 100%; }
  .nav-links a { display: block; padding: 0.65rem 0; font-size: 1rem; }
}

/* ---- Layout primitives ------------------------------------------------- */
.container {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 clamp(1.25rem, 4vw, 3rem);
}

.section { padding: clamp(4.5rem, 10vh, 7.5rem) 0; }

.section-head {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: clamp(2rem, 5vh, 3.25rem);
}

.section-index {
  font-family: var(--font-display);
  font-size: 0.95rem;
  color: var(--accent);
  letter-spacing: 0.12em;
}

.section-title {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  margin: 0;
  position: relative;
  padding-bottom: 0.45rem;
}
.section-title::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 3.5rem;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent-hot), transparent);
  border-radius: 2px;
}

/* ---- Glass surfaces ---------------------------------------------------- */
.glass {
  background: var(--surface-solid);
  border: 1px solid var(--surface-border);
  border-radius: 18px;
}
@supports (backdrop-filter: blur(1px)) {
  .glass {
    background: var(--surface);
    backdrop-filter: blur(14px) saturate(1.2);
  }
}

.panel { padding: clamp(1.5rem, 3.5vw, 2.5rem); }

/* ---- Hero --------------------------------------------------------------- */
.hero {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  position: relative;
  padding: 6rem clamp(1.25rem, 4vw, 3rem) 4rem;
}

.hero-overline {
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 1.4rem;
}
.hero-overline .sep { color: var(--accent); padding: 0 0.5em; }

.hero-name {
  font-size: clamp(2.8rem, 9vw, 5.8rem);
  font-weight: 500;
  margin: 0;
  min-height: 1.2em;
  background: linear-gradient(120deg, #f1f3fa 30%, #b6bdf5 65%, #a78bfa 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.hero-name .caret {
  display: inline-block;
  width: 0.045em;
  min-width: 2px;
  height: 0.9em;
  margin-left: 0.06em;
  vertical-align: -0.08em;
  background: var(--accent);
  -webkit-text-fill-color: initial;
  animation: caret-blink 1.1s steps(1) infinite;
}
.hero-name .caret.done { animation: caret-fade 0.8s ease 1.2s forwards, caret-blink 1.1s steps(1) infinite; }
@keyframes caret-blink { 50% { opacity: 0; } }
@keyframes caret-fade { to { opacity: 0; width: 0; margin: 0; } }

.hero-tagline {
  max-width: 38rem;
  margin: 1.6rem auto 2.4rem;
  font-size: clamp(1.05rem, 2vw, 1.25rem);
  color: var(--text-body);
}

.hero-actions { display: flex; gap: 1rem; flex-wrap: wrap; justify-content: center; }

.btn {
  display: inline-block;
  padding: 0.7rem 1.6rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  border: 1px solid var(--surface-border);
  transition: transform 0.3s var(--ease-out), box-shadow 0.3s ease, border-color 0.3s ease, background 0.3s ease;
}
.btn:hover { transform: translateY(-2px); text-shadow: none; }

.btn-primary {
  background: linear-gradient(120deg, rgba(99, 102, 241, 0.9), rgba(139, 92, 246, 0.9));
  color: #fff;
  border-color: transparent;
}
.btn-primary:hover { box-shadow: var(--glow); color: #fff; }

.btn-ghost { color: var(--text-hi); background: var(--surface); }
.btn-ghost:hover { border-color: rgba(129, 140, 248, 0.4); color: var(--text-hi); }

.scroll-cue {
  position: absolute;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  color: var(--text-muted);
  font-size: 1.4rem;
  animation: cue-drift 2.4s ease-in-out infinite;
}
@keyframes cue-drift {
  0%, 100% { transform: translate(-50%, 0); opacity: 0.55; }
  50% { transform: translate(-50%, 8px); opacity: 1; }
}

/* staged hero entrance (plays once on load; gated on .js) */
.js .hero [data-stage] { opacity: 0; transform: translateY(18px); }
.js .hero.is-live [data-stage] {
  animation: stage-in 0.9s var(--ease-out) forwards;
  animation-delay: calc(var(--stage, 0) * 180ms);
}
@keyframes stage-in { to { opacity: 1; transform: none; } }

/* ---- Scroll reveals ----------------------------------------------------- */
.js [data-reveal] {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.7s ease, transform 0.7s var(--ease-out);
  transition-delay: calc(var(--reveal-delay, 0) * 90ms);
}
.js [data-reveal].is-visible { opacity: 1; transform: none; }

/* ---- About -------------------------------------------------------------- */
.about-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: clamp(1.5rem, 4vw, 3rem);
  align-items: start;
}
@media (max-width: 760px) { .about-grid { grid-template-columns: 1fr; } }

.portrait-card { padding: 1rem; text-align: center; }
.portrait-card img { border-radius: 12px; width: 100%; height: auto; display: block; }
.portrait-card figcaption { font-size: 0.85rem; margin-top: 0.7rem; }
.portrait-card figure { margin: 0; }

.about-lead { font-size: clamp(1.05rem, 1.8vw, 1.2rem); }

/* ---- Project cards ------------------------------------------------------ */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
}

.project-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: var(--text-body);
  transition: transform 0.35s var(--ease-out), box-shadow 0.35s ease, border-color 0.35s ease;
}
.project-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--glow);
  border-color: rgba(129, 140, 248, 0.35);
  text-shadow: none;
}

.project-card .media {
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border-bottom: 1px solid var(--surface-border);
}
.project-card .media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.6s var(--ease-out);
}
.project-card:hover .media img { transform: scale(1.04); }

.project-card .body {
  padding: 1.1rem 1.3rem 1.3rem;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}
.project-card .title {
  font-family: var(--font-display);
  font-size: 1.08rem;
  font-weight: 600;
  color: var(--text-hi);
  margin: 0;
}
.project-card .arrow { color: var(--accent); flex: none; transition: transform 0.3s var(--ease-out); }
.project-card:hover .arrow { transform: translateX(4px); }

/* ---- Experience --------------------------------------------------------- */
.exp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.panel h3, .panel h4 {
  margin-top: 0;
  font-family: var(--font-display);
  font-weight: 600;
}
.panel .panel-kicker {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 0.6rem;
}

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  position: relative;
  padding: 0 0 1.4rem 1.6rem;
  border-left: 1px solid var(--surface-border);
  margin-left: 0.4rem;
}
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 0.5em;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px rgba(129, 140, 248, 0.8);
}
.timeline .when {
  font-size: 0.85rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.cert-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.55rem 0;
  border-bottom: 1px dashed var(--surface-border);
}
.cert-row:last-child { border-bottom: none; }
.cert-row small { color: var(--text-muted); flex: none; }

/* ---- Writing cards ------------------------------------------------------ */
.writing-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
}

.writing-card {
  padding: 1.4rem 1.5rem;
  color: var(--text-body);
  transition: transform 0.35s var(--ease-out), box-shadow 0.35s ease, border-color 0.35s ease;
}
.writing-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--glow);
  border-color: rgba(129, 140, 248, 0.35);
  text-shadow: none;
}
.writing-card .num {
  font-family: var(--font-display);
  color: var(--accent);
  font-size: 0.9rem;
  letter-spacing: 0.1em;
  display: block;
  margin-bottom: 0.5rem;
}
.writing-card .title {
  font-family: var(--font-display);
  font-size: 1.12rem;
  font-weight: 600;
  color: var(--text-hi);
  margin: 0;
}

/* ---- Footer / contact ---------------------------------------------------- */
.site-footer {
  border-top: 1px solid var(--surface-border);
  padding: 4.5rem 0 2.5rem;
  text-align: center;
}

.contact-kicker {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 0.6rem;
}

/* email is plain text, written with [at] on purpose — keep it unlinked so bots can't scrape it */
.contact-email {
  font-family: var(--font-display);
  font-size: clamp(1.3rem, 3.5vw, 2.1rem);
  font-weight: 500;
  color: var(--text-hi);
  margin: 0 0 2.2rem;
  user-select: all;
  word-break: break-word;
}
.footer-links { display: flex; gap: 1.75rem; justify-content: center; flex-wrap: wrap; margin-bottom: 1.5rem; }
.footer-fine { color: var(--text-muted); font-size: 0.85rem; }

/* ---- Article pages (projects & blog) ------------------------------------- */
.article-shell {
  max-width: var(--prose);
  margin: 0 auto;
  padding: 8rem clamp(1.25rem, 4vw, 2rem) 5rem;
}

.back-link {
  display: inline-block;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 2rem;
}
.back-link::before { content: "\2190"; margin-right: 0.45em; color: var(--accent); }
.back-link:hover { color: var(--text-hi); text-shadow: none; }

.article-title {
  font-size: clamp(1.9rem, 5vw, 2.8rem);
  margin: 0 0 0.6rem;
}
.article-meta {
  color: var(--text-muted);
  font-size: 0.9rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 2.5rem;
}

.prose h4 { font-family: var(--font-display); font-size: 1.45rem; margin: 2.4rem 0 0.8rem; }
.prose h6 {
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 2.2rem 0 0.6rem;
}
.prose figure { margin: 2rem 0; }
.prose img { border-radius: 12px; }
.prose figcaption { font-size: 0.85rem; text-align: center; margin-top: 0.6rem; }
.prose ul, .prose ol { padding-left: 1.3rem; }
.prose li { margin-bottom: 0.45rem; }
.prose li::marker { color: var(--accent); }

.equation-container {
  overflow-x: auto;
  padding: 0.5rem 0;
}

/* ---- Misc --------------------------------------------------------------- */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 20;
  background: var(--surface-solid);
  color: var(--text-hi);
  padding: 0.6rem 1rem;
  border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

.center-page {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  position: relative;
  z-index: 2;
  padding: 2rem;
}
.center-page h1 { font-size: clamp(2.2rem, 7vw, 4rem); margin-bottom: 0.5rem; }

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