/* ============================================================
   Ritvik Singh — Portfolio
   Aesthetic: terminal-inspired, dark, disciplined
   ============================================================ */

:root {
  --bg:        #0a0d0f;
  --bg-elev:  #11161a;
  --bg-soft:  #161c21;
  --line:     #1f272d;
  --line-2:   #2a343c;
  --text:     #e6e8ea;
  --text-dim: #9aa3ab;
  --text-mut: #6b7480;
  --accent:   oklch(0.78 0.16 145);     /* terminal green */
  --accent-2: oklch(0.78 0.12 75);      /* amber */
  --danger:   oklch(0.72 0.16 25);      /* red for "secured" badge */
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Inter", -apple-system, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: inherit; text-decoration: none; }
a:focus-visible { outline: 1px solid var(--accent); outline-offset: 3px; }

/* ----------------- Background grid ------------------- */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(to right,  rgba(255,255,255,0.018) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255,255,255,0.018) 1px, transparent 1px);
  background-size: 64px 64px;
  z-index: 0;
  mask-image: radial-gradient(ellipse at top, rgba(0,0,0,0.9), transparent 80%);
}

/* ----------------- Layout shell ------------------- */
.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 40px;
  position: relative;
  z-index: 1;
}

main {
  flex: 1;
  padding: 64px 0 120px;
  position: relative;
  z-index: 1;
}

/* ----------------- Header ------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(10, 13, 15, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 500;
}
.brand-mark {
  width: 28px;
  height: 28px;
  border: 1px solid var(--accent);
  display: grid;
  place-items: center;
  color: var(--accent);
  font-weight: 600;
  letter-spacing: 0;
}
.brand-name { color: var(--text); }
.brand-tail { color: var(--text-mut); }

.nav {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: var(--mono);
  font-size: 13px;
}
.nav a {
  padding: 8px 14px;
  color: var(--text-dim);
  border: 1px solid transparent;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.nav a:hover { color: var(--text); background: rgba(255,255,255,0.025); }
.nav a.is-active {
  color: var(--accent);
  border-color: var(--line-2);
  background: var(--bg-elev);
}
.nav-num {
  color: var(--text-mut);
  margin-right: 6px;
  font-size: 11px;
}

/* ----------------- Footer ------------------- */
.site-footer {
  border-top: 1px solid var(--line);
  background: var(--bg);
  padding: 28px 0;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-mut);
  position: relative;
  z-index: 1;
}
.site-footer .wrap {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}
.footer-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  animation: pulse 2.2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.35; }
}

/* ----------------- Typography ------------------- */
h1, h2, h3, h4 {
  font-family: var(--mono);
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--text);
  margin: 0;
}
h1 { font-size: clamp(38px, 5.5vw, 68px); line-height: 1.05; letter-spacing: -0.03em; }
h2 { font-size: 28px; line-height: 1.2; }
h3 { font-size: 18px; line-height: 1.3; }

p { margin: 0 0 1em; color: var(--text-dim); }
p.lead { font-size: 17px; color: var(--text); line-height: 1.55; max-width: 60ch; }

/* ----------------- Section header ------------------- */
.section-label {
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-mut);
  margin-bottom: 28px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.section-label::before {
  content: "";
  width: 24px;
  height: 1px;
  background: var(--accent);
}
.section-label .idx {
  color: var(--accent);
  font-weight: 500;
}

/* Page intro */
.page-intro {
  padding: 24px 0 56px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 56px;
}
.page-intro .crumbs {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-mut);
  margin-bottom: 20px;
}
.page-intro .crumbs .sep { margin: 0 8px; color: var(--line-2); }
.page-intro .crumbs .cur { color: var(--accent); }
.page-intro h1 { margin-bottom: 18px; }

/* ----------------- Cards / panels ------------------- */
.panel {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  padding: 28px;
  position: relative;
}
.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.panel-head .meta {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-mut);
}

/* ----------------- Buttons / chips ------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  border: 1px solid var(--line-2);
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text);
  background: transparent;
  transition: all 0.15s;
  cursor: pointer;
}
.btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(0,0,0,0.2);
}
.btn-primary {
  border-color: var(--accent);
  color: var(--accent);
}
.btn-primary:hover {
  background: var(--accent);
  color: var(--bg);
}
.btn .arr { transition: transform 0.15s; }
.btn:hover .arr { transform: translateX(3px); }

.chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border: 1px solid var(--line-2);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  background: var(--bg-soft);
  letter-spacing: 0.02em;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* ----------------- Terminal block ------------------- */
.term {
  background: #07090a;
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-dim);
}
.term-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-elev);
}
.term-head .dots { display: flex; gap: 6px; }
.term-head .dots i {
  width: 9px; height: 9px; border-radius: 50%; display: block;
  background: var(--line-2);
}
.term-head .title {
  font-size: 11px;
  color: var(--text-mut);
  letter-spacing: 0.05em;
}
.term-body { padding: 18px 18px 22px; }
.term-line { display: block; white-space: pre-wrap; }
.term-prompt { color: var(--accent); }
.term-comment { color: var(--text-mut); }
.term-out { color: var(--text); }
.term-key { color: var(--accent-2); }

.cursor::after {
  content: "▊";
  color: var(--accent);
  margin-left: 2px;
  animation: blink 1.05s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* ----------------- Utility ------------------- */
.row { display: flex; gap: 16px; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.divider { height: 1px; background: var(--line); margin: 56px 0; border: 0; }
.mono { font-family: var(--mono); }
.dim { color: var(--text-dim); }
.mut { color: var(--text-mut); }
.acc { color: var(--accent); }
.num, .stat .num, .blog-stat .num, .metric-row .num {
  font-variant-numeric: tabular-nums;
}

@media (max-width: 800px) {
  .wrap { padding: 0 22px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; gap: 20px; }
  .nav a { padding: 8px 10px; }
  .nav-num { display: none; }
  main { padding: 32px 0 80px; }
}

/* ----------------- Hamburger toggle button ------------------- */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--line-2);
  cursor: pointer;
  flex-shrink: 0;
}
.nav-toggle span {
  display: block;
  width: 18px;
  height: 1px;
  background: var(--text-dim);
  transition: transform 0.22s ease, opacity 0.22s ease;
  transform-origin: center;
}
.nav-toggle.is-open span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.nav-toggle.is-open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.nav-toggle.is-open span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* ----------------- Mobile nav (≤ 700 px) ------------------- */
@media (max-width: 700px) {
  .nav-toggle { display: flex; }

  .nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 0;
    padding: 4px 0 8px;
    background: rgba(10, 13, 15, 0.97);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--line);
    z-index: 20;
  }
  .nav.is-open { display: flex; }

  .nav a {
    padding: 14px 22px;
    border: 0;
    border-bottom: 1px solid var(--line);
    font-size: 14px;
    letter-spacing: 0;
  }
  .nav a:last-child { border-bottom: 0; }
  .nav a::after { display: none; }
  .nav .nav-num { display: inline; margin-right: 10px; }
}

/* ----------------- Extra small screens (≤ 480 px) ------------------- */
@media (max-width: 480px) {
  .wrap { padding: 0 16px; }
  .brand-tail { display: none; }
  .term-body { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .cta { flex-direction: column; }
  .hero-actions { flex-direction: column; }
  .hero-actions .btn { width: 100%; justify-content: center; }
}

/* ============================================================
   MOTION — page transitions, scroll reveal, micro-animations
   ============================================================ */

/* Page enter / leave — body stays visible on load (no blank flash while JS runs). */
html.js-enabled.is-leaving body {
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.28s ease, transform 0.28s ease;
}

/* Reveal-on-scroll */
.reveal {
  opacity: 0;
  transform: translateY(16px);
  transition:
    opacity 0.6s cubic-bezier(.2,.6,.2,1) var(--reveal-delay, 0ms),
    transform 0.6s cubic-bezier(.2,.6,.2,1) var(--reveal-delay, 0ms);
  will-change: opacity, transform;
}
.reveal.is-revealed {
  opacity: 1;
  transform: none;
}

/* Header slide-in */
html.js-enabled .site-header {
  animation: slideHeader 0.5s cubic-bezier(.2,.6,.2,1) both;
}
@keyframes slideHeader {
  from { transform: translateY(-100%); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

/* Hero terminal: lines type in sequentially */
html.js-enabled .term-body > .term-line,
html.js-enabled .term-body > br {
  opacity: 0;
  animation: termLine 0.35s ease forwards;
}
html.js-enabled .term-body > *:nth-child(1)  { animation-delay: 0.25s; }
html.js-enabled .term-body > *:nth-child(2)  { animation-delay: 0.40s; }
html.js-enabled .term-body > *:nth-child(3)  { animation-delay: 0.55s; }
html.js-enabled .term-body > *:nth-child(4)  { animation-delay: 0.70s; }
html.js-enabled .term-body > *:nth-child(5)  { animation-delay: 0.85s; }
html.js-enabled .term-body > *:nth-child(6)  { animation-delay: 1.00s; }
html.js-enabled .term-body > *:nth-child(7)  { animation-delay: 1.10s; }
html.js-enabled .term-body > *:nth-child(8)  { animation-delay: 1.20s; }
html.js-enabled .term-body > *:nth-child(9)  { animation-delay: 1.30s; }
html.js-enabled .term-body > *:nth-child(10) { animation-delay: 1.40s; }
html.js-enabled .term-body > *:nth-child(11) { animation-delay: 1.55s; }
html.js-enabled .term-body > *:nth-child(12) { animation-delay: 1.70s; }
html.js-enabled .term-body > *:nth-child(13) { animation-delay: 1.85s; }
html.js-enabled .term-body > *:nth-child(14) { animation-delay: 2.00s; }
@keyframes termLine {
  from { opacity: 0; transform: translateX(-6px); }
  to   { opacity: 1; transform: none; }
}

/* Brand mark subtle pulse on enter */
html.js-enabled.is-loaded .brand-mark {
  animation: markFade 0.6s ease both;
}
@keyframes markFade {
  from { box-shadow: 0 0 0 0 var(--accent); }
  to   { box-shadow: 0 0 0 8px rgba(120,200,140,0); }
}

/* Skill bar fill animation */
html.js-enabled .skill-row .bar i {
  width: 0 !important;
  transition: width 1s cubic-bezier(.2,.6,.2,1);
}
html.js-enabled .reveal.is-revealed .skill-row .bar i,
html.js-enabled .skill-block.is-revealed .skill-row .bar i {
  width: var(--bar-w, 0%) !important;
}

/* Nav link underline animation */
.nav a {
  position: relative;
}
.nav a::after {
  content: "";
  position: absolute;
  left: 14px; right: 14px; bottom: 6px;
  height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.25s cubic-bezier(.2,.6,.2,1);
}
.nav a:hover::after { transform: scaleX(0.7); }
.nav a.is-active::after { transform: scaleX(1); }

/* Buttons - subtle press */
.btn:active { transform: translateY(1px); }
.btn { transition: all 0.18s ease, transform 0.08s ease; }

/* Hover lift for compact cards */
.project, .panel, .channel, .post-row, .recent-item, .role-card, .timeline-item, .focus, .stat, .avail, .blog-stat, .approach .step {
  transition:
    transform 0.22s cubic-bezier(.2,.6,.2,1),
    border-color 0.18s ease,
    background 0.18s ease,
    padding 0.18s ease;
}

/* Status pulse already exists; bring footer dot in sync */
.footer-status .dot,
.dot {
  animation: pulse 2.2s ease-in-out infinite;
}

/* Cursor pulse a touch more lively */
.cursor::after {
  animation: blink 1.05s steps(2) infinite;
}

/* Anchor scroll smoothing */
html { scroll-behavior: smooth; }

/* Anchor targets clear the sticky header */
[id] { scroll-margin-top: 80px; }

/* Branded text selection */
::selection { background: rgba(120,200,140,0.2); color: var(--text); }

/* ============================================================
   SITE LOADER — terminal boot sequence
   ============================================================ */
.site-loader {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
  background-image:
    linear-gradient(rgba(120, 200, 140, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(120, 200, 140, 0.03) 1px, transparent 1px);
  background-size: 32px 32px;
  transition:
    opacity 0.45s cubic-bezier(0.2, 0.6, 0.2, 1),
    visibility 0.45s cubic-bezier(0.2, 0.6, 0.2, 1);
}
.site-loader.site-loader--out {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.site-loader-panel {
  width: 100%;
  max-width: 400px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.55);
}
.site-loader-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--line);
}
.site-loader-head .sl-dots { display: flex; gap: 6px; }
.site-loader-head .sl-dots i {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--line-2); display: block;
}
.site-loader-head .sl-file {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-mut);
  margin-left: 4px;
  letter-spacing: 0.04em;
}
.site-loader-body { padding: 22px 22px 20px; }
.site-loader-brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.site-loader-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 600;
  color: var(--accent);
  border: 1px solid var(--line-2);
  background: var(--bg-soft);
  flex-shrink: 0;
}
.site-loader-title {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}
.site-loader-sub {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-mut);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 3px;
}
.site-loader-lines { margin-bottom: 18px; }
.sl-line {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
  padding: 3px 0;
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity 0.22s ease, transform 0.22s ease;
  line-height: 1.6;
}
.sl-line.sl-show { opacity: 1; transform: none; }
.sl-line .sl-p    { color: var(--accent); }
.sl-line .sl-ok   { color: var(--accent); }
.sl-line .sl-mu   { color: var(--text-mut); }
.sl-line .sl-fail { color: oklch(0.65 0.2 25); }
.site-loader-bar {
  height: 2px;
  background: var(--line);
  overflow: hidden;
  margin-bottom: 10px;
}
.site-loader-bar-fill {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 8px var(--accent);
}
.site-loader-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-mut);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.site-loader-pct {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

/* Minimal loader — non-home navigation */
.site-loader--minimal {
  background: transparent;
  background-image: none;
  pointer-events: none;
  transition-duration: 0.22s;
}
.sl-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  overflow: hidden;
  z-index: 2147483001;
}

/* Loader — mobile */
@media (max-width: 480px) {
  .site-loader { padding: 14px; }
  .site-loader-body { padding: 14px 14px 12px; }
  .site-loader-title { font-size: 13px; }
  .sl-line {
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .site-loader-bar-fill { transition: none !important; width: 100%; box-shadow: none; }
  .sl-line { transition: none; opacity: 1; transform: none; }
  html.js-enabled body,
  html.js-enabled.is-leaving body { transition: none; transform: none; }
  .reveal { opacity: 1; transform: none; transition: none; }
  html.js-enabled .term-body > .term-line,
  html.js-enabled .term-body > br { opacity: 1; animation: none; }
  html.js-enabled .skill-row .bar i { transition: none; }
  html.js-enabled .site-header { animation: none; }
  html { scroll-behavior: auto; }
  .dot, .cursor::after { animation: none; }
}
