/* ===========================================================================
   Gaurav Sharma — portfolio
   Dark, typographic, with a live 3D system behind the content.

   Palette is deliberately not the default "AI portfolio" purple-on-black:
   deep navy base, mint/teal primary, warm sand secondary. Warm + cool reads
   as engineered rather than decorative.
   ======================================================================== */

:root {
  --bg:            #05070E;
  --bg-raised:     #0B0F1A;
  --surface:       rgba(255, 255, 255, 0.035);
  --surface-hover: rgba(255, 255, 255, 0.06);
  --line:          rgba(255, 255, 255, 0.09);
  --line-strong:   rgba(255, 255, 255, 0.16);

  --text:          #E8EEF9;
  --text-muted:    #8E9AB0;
  --text-dim:      #5D697E;

  --mint:          #5EE7C6;
  --mint-dim:      #2E9A83;
  --sand:          #F0A868;
  --sky:           #8AB4F8;

  --font-sans:  'Inter', system-ui, -apple-system, sans-serif;
  --font-serif: 'Instrument Serif', Georgia, serif;
  --font-mono:  'JetBrains Mono', ui-monospace, monospace;

  --page:   min(1180px, 100% - 3rem);
  --radius: 14px;
  --ease:   cubic-bezier(0.22, 1, 0.36, 1);
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.65;
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: inherit; }

::selection { background: var(--mint); color: #04121A; }

/* --- 3D canvas + film grain ---------------------------------------------- */

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  display: block;
  opacity: 0;
  transition: opacity 1.6s var(--ease);
}
/*
 * Once loaded, the scene's strength is driven by --scene-dim, which the scroll
 * handler lowers as the reader leaves the hero. The hero is where the 3D earns
 * its place; past it, competing with body copy is the only thing it can do.
 */
#scene.is-ready { opacity: var(--scene-dim, 1); transition: opacity 0.45s linear; }

.grain {
  position: fixed;
  inset: -50%;
  z-index: 1;
  pointer-events: none;
  opacity: 0.16;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
  animation: grain 7s steps(6) infinite;
}
@keyframes grain {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-4%, 3%); }
  40% { transform: translate(3%, -4%); }
  60% { transform: translate(-3%, -3%); }
  80% { transform: translate(4%, 2%); }
}

main, .nav, .footer { position: relative; z-index: 2; }

/* --- Loader -------------------------------------------------------------- */

.loader {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-content: center;
  gap: 1.1rem;
  background: var(--bg);
  transition: opacity 0.7s var(--ease), visibility 0.7s;
}
.loader.is-done { opacity: 0; visibility: hidden; }
.loader__bar {
  width: 190px;
  height: 1px;
  background: var(--line);
  overflow: hidden;
}
.loader__bar span {
  display: block;
  height: 100%;
  width: 40%;
  background: var(--mint);
  animation: load 1.1s var(--ease) infinite;
}
@keyframes load {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}
.loader__text {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-dim);
  text-align: center;
}

/* --- Navigation ---------------------------------------------------------- */

.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1.1rem max(1.5rem, calc((100vw - var(--page)) / 2));
  backdrop-filter: blur(14px);
  background: linear-gradient(180deg, rgba(5, 7, 14, 0.85), rgba(5, 7, 14, 0));
  transition: background 0.4s var(--ease);
}
.nav__mark {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-decoration: none;
}
.nav__dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 14px var(--mint);
  animation: breathe 2.8s ease-in-out infinite;
}
@keyframes breathe {
  0%, 100% { opacity: 1;   transform: scale(1); }
  50%      { opacity: 0.45; transform: scale(0.8); }
}
.nav__links {
  display: flex;
  gap: 2rem;
  font-size: 0.86rem;
  color: var(--text-muted);
}
.nav__links a {
  text-decoration: none;
  position: relative;
  padding-block: 2px;
  transition: color 0.25s;
}
.nav__links a::after {
  content: '';
  position: absolute;
  left: 0; bottom: 0;
  width: 100%; height: 1px;
  background: var(--mint);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.35s var(--ease);
}
.nav__links a:hover { color: var(--text); }
.nav__links a:hover::after,
.nav__links a.is-active::after { transform: scaleX(1); }
.nav__links a.is-active { color: var(--text); }

.nav__cta {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 0.1em;
  text-decoration: none;
  padding: 0.5rem 1rem;
  border: 1px solid var(--line-strong);
  border-radius: 100px;
  color: var(--text);
  transition: border-color 0.3s, background 0.3s, color 0.3s;
}
.nav__cta:hover {
  border-color: var(--mint);
  background: rgba(94, 231, 198, 0.1);
  color: var(--mint);
}

/* --- Hero ---------------------------------------------------------------- */

.hero {
  min-height: 100svh;
  display: grid;
  align-content: center;
  width: var(--page);
  margin-inline: auto;
  padding-block: 8rem 4rem;
  position: relative;
}
.hero__inner {
  max-width: 60ch;
  position: relative;
  z-index: 1;
}

/*
 * Readability scrim. The particle field drifts across the whole viewport, so
 * without this the body copy sits on an unpredictable background and contrast
 * fails exactly where it matters most. Sized and feathered so it reads as
 * depth rather than as a visible box.
 */
.hero__inner::before {
  content: '';
  position: absolute;
  inset: -16% -32% -16% -44%;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(
    ellipse 70% 60% at 28% 50%,
    rgba(5, 7, 14, 0.94) 0%,
    rgba(5, 7, 14, 0.82) 38%,
    rgba(5, 7, 14, 0.45) 66%,
    transparent 100%
  );
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0 0 1.8rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.pulse {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 0 0 rgba(94, 231, 198, 0.7);
  animation: ping 2.4s var(--ease) infinite;
}
@keyframes ping {
  0%   { box-shadow: 0 0 0 0 rgba(94, 231, 198, 0.6); }
  70%  { box-shadow: 0 0 0 11px rgba(94, 231, 198, 0); }
  100% { box-shadow: 0 0 0 0 rgba(94, 231, 198, 0); }
}

.hero__title {
  margin: 0 0 1.6rem;
  font-size: clamp(2.7rem, 7.5vw, 5.2rem);
  line-height: 1.02;
  font-weight: 300;
  letter-spacing: -0.035em;
}
.hero__title .line { display: block; }
.serif {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  letter-spacing: -0.015em;
  background: linear-gradient(104deg, var(--mint) 10%, var(--sky) 55%, var(--sand) 95%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero__lede {
  margin: 0 0 1.1rem;
  font-size: clamp(1.1rem, 2.1vw, 1.42rem);
  line-height: 1.45;
  color: var(--text);
  font-weight: 300;
  max-width: 34ch;
}
.hero__intro {
  margin: 0 0 2.6rem;
  color: var(--text-muted);
  max-width: 52ch;
  font-size: 1rem;
}

.hero__actions { display: flex; flex-wrap: wrap; gap: 0.8rem; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.78rem 1.4rem;
  border: 1px solid var(--line-strong);
  border-radius: 100px;
  font-size: 0.88rem;
  text-decoration: none;
  color: var(--text);
  background: var(--surface);
  transition: transform 0.3s var(--ease), border-color 0.3s, background 0.3s;
}
.btn:hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
  background: var(--surface-hover);
}
.btn--primary {
  background: var(--mint);
  border-color: var(--mint);
  color: #04121A;
  font-weight: 500;
}
.btn--primary:hover {
  background: #7CF0D4;
  border-color: #7CF0D4;
  box-shadow: 0 10px 34px -10px rgba(94, 231, 198, 0.65);
}

.hero__scroll {
  position: absolute;
  bottom: 2.4rem; left: 0;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.hero__scroll-line {
  display: block;
  width: 52px; height: 1px;
  background: linear-gradient(90deg, var(--mint), transparent);
  animation: slide 2.4s var(--ease) infinite;
}
@keyframes slide {
  0%, 100% { transform: scaleX(0.3); transform-origin: left; opacity: 0.4; }
  50%      { transform: scaleX(1);   transform-origin: left; opacity: 1; }
}

/* --- Metrics ------------------------------------------------------------- */

.metrics {
  width: var(--page);
  margin: 0 auto;
  padding-block: 3rem 6rem;
  border-top: 1px solid var(--line);
}
.metrics__grid {
  list-style: none;
  margin: 0; padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 2.2rem 1.5rem;
}
.metric__value {
  display: block;
  font-size: clamp(2.2rem, 4.4vw, 3.1rem);
  font-weight: 300;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--mint);
  font-variant-numeric: tabular-nums;
}
.metric__label {
  display: block;
  margin-top: 0.7rem;
  font-size: 0.93rem;
  color: var(--text);
}
.metric__detail {
  display: block;
  margin-top: 0.2rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-dim);
}

/* --- Sections ------------------------------------------------------------ */

.section {
  width: var(--page);
  margin-inline: auto;
  padding-block: clamp(5rem, 11vw, 9rem);
  position: relative;
}
/* Same contrast guarantee as the hero, dialled down — section cards already
   carry their own translucent background, so only the headings need help. */
.section__head { position: relative; z-index: 1; }
.section__head::before {
  content: '';
  position: absolute;
  inset: -22% -30%;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(
    ellipse 62% 70% at 22% 50%,
    rgba(5, 7, 14, 0.88) 0%,
    rgba(5, 7, 14, 0.5) 55%,
    transparent 100%
  );
}
.section__head { max-width: 62ch; margin-bottom: 3.6rem; }
.section__index {
  margin: 0 0 1rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.26em;
  color: var(--mint-dim);
}
.section__title {
  margin: 0 0 0.9rem;
  font-size: clamp(1.9rem, 4.4vw, 3rem);
  font-weight: 300;
  letter-spacing: -0.032em;
  line-height: 1.1;
}
.section__sub { margin: 0; color: var(--text-muted); font-size: 1.02rem; }

/* --- Timeline ------------------------------------------------------------ */

.timeline { display: grid; gap: 1.1rem; }

.role {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(8, 11, 20, 0.88);
  backdrop-filter: blur(16px);
  overflow: hidden;
  transition: border-color 0.4s var(--ease), transform 0.4s var(--ease);
}
.role:hover { border-color: var(--line-strong); }
.role.is-open { border-color: color-mix(in srgb, var(--role-accent) 55%, transparent); }

.role__head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem 2rem;
  align-items: start;
  width: 100%;
  padding: 1.7rem 1.8rem;
  background: none;
  border: 0;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.role__company {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 1.22rem;
  font-weight: 400;
  letter-spacing: -0.01em;
}
.role__node {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--role-accent);
  box-shadow: 0 0 12px var(--role-accent);
  flex: none;
}
.role__role { margin: 0.3rem 0 0; color: var(--text-muted); font-size: 0.95rem; }
.role__meta {
  font-family: var(--font-mono);
  font-size: 0.73rem;
  color: var(--text-dim);
  text-align: right;
  white-space: nowrap;
}
.role__chev {
  display: inline-block;
  margin-left: 0.6rem;
  transition: transform 0.4s var(--ease);
  color: var(--role-accent);
}
.role.is-open .role__chev { transform: rotate(180deg); }

.role__body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.5s var(--ease);
}
.role.is-open .role__body { grid-template-rows: 1fr; }
.role__bodyInner { overflow: hidden; }
.role__content {
  padding: 0 1.8rem 1.9rem;
  border-top: 1px solid var(--line);
  margin-top: 0.2rem;
  padding-top: 1.4rem;
}
.role__summary { margin: 0 0 1.3rem; color: var(--text-muted); max-width: 70ch; }
.role__list { margin: 0 0 1.5rem; padding: 0; list-style: none; display: grid; gap: 0.75rem; }
.role__list li {
  position: relative;
  padding-left: 1.4rem;
  color: var(--text);
  font-size: 0.95rem;
  max-width: 76ch;
}
.role__list li::before {
  content: '';
  position: absolute;
  left: 0; top: 0.65em;
  width: 7px; height: 1px;
  background: var(--role-accent);
}
.chips { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.chip {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 0.3rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 100px;
  color: var(--text-muted);
  transition: border-color 0.3s, color 0.3s;
}
.chip:hover { border-color: var(--role-accent); color: var(--text); }

/* --- System map ---------------------------------------------------------- */

.sysmap {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 1.1rem;
  align-items: stretch;
}
.sysmap__stage {
  position: relative;
  min-height: 460px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    radial-gradient(ellipse at 50% 40%, rgba(94, 231, 198, 0.07), transparent 62%),
    rgba(8, 11, 20, 0.9);
  backdrop-filter: blur(16px);
  overflow: hidden;
}
.sysmap__stage svg { display: block; width: 100%; height: 100%; }

.sysnode { cursor: pointer; }
.sysnode circle { transition: r 0.3s var(--ease), fill-opacity 0.3s; }
.sysnode:hover circle, .sysnode.is-active circle { fill-opacity: 0.32; }
.sysnode text {
  font-family: var(--font-mono);
  font-size: 9.5px;
  fill: var(--text-muted);
  text-anchor: middle;
  pointer-events: none;
  transition: fill 0.3s;
}
.sysnode:hover text, .sysnode.is-active text { fill: var(--text); }

.sysmap__panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(8, 11, 20, 0.9);
  backdrop-filter: blur(16px);
  padding: 1.5rem;
  font-size: 0.9rem;
}
.sysmap__hint { margin: 0; color: var(--text-dim); font-size: 0.84rem; }
.sysmap__panel h3 {
  margin: 0 0 0.2rem;
  font-size: 1.02rem;
  font-weight: 500;
  color: var(--text);
}
.sysmap__kind {
  margin: 0 0 0.9rem;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--mint);
}
.sysmap__panel p { color: var(--text-muted); margin: 0 0 0.9rem; }
.sysmap__tech {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-dim);
  border-top: 1px solid var(--line);
  padding-top: 0.8rem;
}

/* --- Skills -------------------------------------------------------------- */

.skills {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 1rem;
}
.skillgroup {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(8, 11, 20, 0.82);
  backdrop-filter: blur(14px);
  padding: 1.4rem 1.5rem 1.6rem;
  transition: border-color 0.35s, transform 0.35s var(--ease);
}
.skillgroup:hover { border-color: var(--line-strong); transform: translateY(-3px); }
.skillgroup h3 {
  margin: 0 0 1rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--mint-dim);
  font-weight: 500;
}
.skillgroup ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 0.5rem; }
.skillgroup li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.93rem;
  color: var(--text);
}
.skillgroup li::before {
  content: '';
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--mint-dim);
  flex: none;
}

/* --- Contact ------------------------------------------------------------- */

.section--contact { padding-bottom: 5rem; }
.contact { max-width: 62ch; }
.contact__title {
  margin: 0 0 1.1rem;
  font-size: clamp(2.6rem, 7vw, 4.6rem);
  line-height: 1;
  font-weight: 400;
}
.contact__body { color: var(--text-muted); margin: 0 0 2.2rem; font-size: 1.04rem; }
.contact__mail {
  display: inline-block;
  font-size: clamp(1.1rem, 2.6vw, 1.6rem);
  text-decoration: none;
  color: var(--text);
  border-bottom: 1px solid var(--line-strong);
  padding-bottom: 0.25rem;
  transition: color 0.3s, border-color 0.3s;
}
.contact__mail:hover { color: var(--mint); border-color: var(--mint); }
.contact__links {
  display: flex;
  flex-wrap: wrap;
  gap: 1.6rem;
  margin-top: 2rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
}
.contact__links a { color: var(--text-muted); text-decoration: none; transition: color 0.25s; }
.contact__links a:hover { color: var(--mint); }
.contact__edu {
  margin-top: 2.6rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--line);
  color: var(--text-dim);
  font-size: 0.86rem;
}

/* --- Footer + motion toggle ---------------------------------------------- */

.footer {
  width: var(--page);
  margin-inline: auto;
  padding-block: 2rem 3rem;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-dim);
}

.motion-toggle {
  position: fixed;
  right: 1.4rem; bottom: 1.4rem;
  z-index: 60;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 100px;
  background: rgba(5, 7, 14, 0.8);
  backdrop-filter: blur(10px);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: color 0.3s, border-color 0.3s;
}
.motion-toggle:hover { color: var(--text); border-color: var(--line-strong); }
.motion-toggle__dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--mint);
  transition: background 0.3s;
}
.motion-toggle[aria-pressed="true"] .motion-toggle__dot { background: var(--text-dim); }

/* --- Reveal animation ---------------------------------------------------- */

[data-reveal] {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 0.9s var(--ease), transform 0.9s var(--ease);
  transition-delay: var(--reveal-delay, 0ms);
}
[data-reveal].is-visible { opacity: 1; transform: none; }

/* --- Responsive ---------------------------------------------------------- */

@media (max-width: 860px) {
  .sysmap { grid-template-columns: 1fr; }
  .sysmap__stage { min-height: 340px; }
  .nav__links { display: none; }
  .role__head { grid-template-columns: 1fr; }
  .role__meta { text-align: left; }
}

@media (max-width: 520px) {
  :root { --page: calc(100% - 2rem); }
  .hero { padding-block: 7rem 5rem; }
  .hero__scroll { display: none; }
}

/* Respect the OS setting: no parallax, no grain, no reveal offsets. */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  [data-reveal] { opacity: 1; transform: none; }
  .grain { display: none; }
}
