/* ============================================================
   Ratheesh.dev — 3D Portfolio
   ============================================================ */
:root {
  --bg: #05060f;
  --bg-2: #0a0d1f;
  --ink: #e8ecff;
  --muted: #8b93b8;
  --accent: #5eead4;
  --accent-2: #818cf8;
  --accent-3: #f472b6;
  --glass: rgba(255, 255, 255, 0.045);
  --glass-border: rgba(255, 255, 255, 0.1);
  --radius: 18px;
  --font-display: "Space Grotesk", sans-serif;
  --font-body: "Inter", sans-serif;
}

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

html { scroll-behavior: smooth; }

body {
  background:
    radial-gradient(1200px 800px at 75% -10%, rgba(129, 140, 248, 0.14), transparent 60%),
    radial-gradient(900px 700px at 10% 110%, rgba(94, 234, 212, 0.1), transparent 55%),
    var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.65;
  overflow-x: hidden;
}

::selection { background: rgba(94, 234, 212, 0.3); }

/* ---------- 3D canvas background ---------- */
#bg3d {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  display: block;
}

.grid-overlay {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,0.028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.028) 1px, transparent 1px);
  background-size: 72px 72px;
  mask-image: radial-gradient(ellipse 90% 70% at 50% 40%, black 30%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 90% 70% at 50% 40%, black 30%, transparent 75%);
}

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

.accent {
  background: linear-gradient(92deg, var(--accent), var(--accent-2) 55%, var(--accent-3));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---------- Nav ---------- */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px min(5vw, 56px);
  transition: background 0.35s ease, backdrop-filter 0.35s ease, border-color 0.35s ease;
  border-bottom: 1px solid transparent;
}
.nav.scrolled {
  background: rgba(5, 6, 15, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom-color: rgba(255,255,255,0.06);
}
.nav-logo {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.02em;
  color: var(--ink);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

/* tiny spinning 3D cube logo */
.logo-cube {
  width: 16px; height: 16px;
  perspective: 120px;
  display: inline-block;
}
.logo-cube span {
  position: relative;
  width: 100%; height: 100%;
  display: block;
  transform-style: preserve-3d;
  animation: cubeSpin 7s linear infinite;
}
.logo-cube span::before,
.logo-cube span::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 1.5px solid var(--accent);
  border-radius: 3px;
}
.logo-cube span::after {
  transform: rotateY(90deg);
  border-color: var(--accent-2);
}
@keyframes cubeSpin {
  from { transform: rotateX(-24deg) rotateY(0deg); }
  to   { transform: rotateX(-24deg) rotateY(360deg); }
}

.nav-links {
  display: flex;
  align-items: center;
  gap: clamp(14px, 2.4vw, 30px);
}
.nav-links a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  transition: color 0.25s ease;
}
.nav-links a:hover { color: var(--ink); }
.nav-cta {
  color: var(--ink) !important;
  border: 1px solid rgba(94, 234, 212, 0.45);
  padding: 8px 18px;
  border-radius: 999px;
  background: rgba(94, 234, 212, 0.08);
  transition: background 0.25s ease, box-shadow 0.25s ease, transform 0.25s ease;
}
.nav-cta:hover {
  background: rgba(94, 234, 212, 0.16);
  box-shadow: 0 0 24px rgba(94, 234, 212, 0.25);
  transform: translateY(-1px);
}

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: 0;
  cursor: pointer;
  padding: 8px;
}
.nav-toggle span {
  width: 22px; height: 2px;
  background: var(--ink);
  border-radius: 2px;
  transition: transform 0.3s ease, opacity 0.3s ease;
}
.nav-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle.open span:nth-child(2) { opacity: 0; }
.nav-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---------- Hero ---------- */
.hero {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 120px min(6vw, 80px) 80px;
  max-width: 1280px;
  margin: 0 auto;
}
.hero-kicker {
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.32em;
  font-size: 0.78rem;
  color: var(--accent);
  margin-bottom: 22px;
}
.hero-title {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 6.4vw, 5rem);
  line-height: 1.06;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.hero-title .cursor {
  color: var(--accent);
  animation: blink 1s steps(1) infinite;
  font-weight: 400;
}
@keyframes blink { 50% { opacity: 0; } }
.hero-sub {
  margin-top: 26px;
  max-width: 560px;
  color: var(--muted);
  font-size: clamp(1rem, 1.5vw, 1.15rem);
}
.hero-actions {
  margin-top: 38px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.btn {
  display: inline-block;
  padding: 13px 30px;
  border-radius: 999px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  letter-spacing: 0.02em;
  transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.25s ease, border-color 0.25s ease;
}
.btn-primary {
  background: linear-gradient(92deg, var(--accent), var(--accent-2));
  color: #060814;
}
.btn-primary:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 40px rgba(94, 234, 212, 0.3);
}
.btn-ghost {
  border: 1px solid rgba(255,255,255,0.22);
  color: var(--ink);
}
.btn-ghost:hover {
  transform: translateY(-3px);
  border-color: rgba(94, 234, 212, 0.55);
  box-shadow: 0 10px 30px rgba(129, 140, 248, 0.2);
}

.hero-stats {
  margin-top: 64px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  max-width: 760px;
}
.stat {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  padding: 16px 18px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.stat strong {
  display: block;
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 3vw, 2.1rem);
  background: linear-gradient(92deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.stat span { color: var(--muted); font-size: 0.8rem; }

.scroll-hint {
  position: absolute;
  bottom: 34px;
  left: 50%;
  transform: translateX(-50%);
  width: 26px; height: 44px;
  border: 2px solid rgba(255,255,255,0.3);
  border-radius: 14px;
  display: flex;
  justify-content: center;
  padding-top: 8px;
  text-decoration: none;
}
.scroll-hint span {
  width: 4px; height: 8px;
  border-radius: 4px;
  background: var(--accent);
  animation: scrollDot 1.6s ease-in-out infinite;
}
@keyframes scrollDot {
  0% { transform: translateY(0); opacity: 1; }
  70% { transform: translateY(14px); opacity: 0; }
  100% { transform: translateY(0); opacity: 0; }
}

/* ---------- Sections ---------- */
.section {
  max-width: 1280px;
  margin: 0 auto;
  padding: clamp(70px, 10vw, 120px) min(5vw, 56px);
  scroll-margin-top: 80px;
}
.section-head { margin-bottom: clamp(36px, 5vw, 56px); }
.section-tag {
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.3em;
  font-size: 0.72rem;
  color: var(--accent);
}
.section-head h2 {
  font-family: var(--font-display);
  font-size: clamp(1.9rem, 4.2vw, 3rem);
  letter-spacing: -0.02em;
  margin-top: 10px;
}

/* ---------- Glass + 3D tilt cards ---------- */
.glass {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.card-3d {
  transform-style: preserve-3d;
  will-change: transform;
  transition: transform 0.18s ease-out, border-color 0.3s ease, box-shadow 0.3s ease;
  position: relative;
}
.card-3d:hover {
  border-color: rgba(94, 234, 212, 0.35);
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(94, 234, 212, 0.12),
    0 0 44px rgba(129, 140, 248, 0.12);
}
/* shine that follows the pointer */
.card-3d::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(420px circle at var(--mx, 50%) var(--my, 50%), rgba(255,255,255,0.07), transparent 45%);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}
.card-3d:hover::after { opacity: 1; }

/* ---------- About ---------- */
.about-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 22px;
}
.about-text { padding: clamp(24px, 4vw, 44px); }
.about-text p + p { margin-top: 18px; }
.about-text strong { color: var(--ink); }
.about-side { display: flex; flex-direction: column; gap: 16px; }
.fact {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 22px;
}
.fact-icon {
  flex: 0 0 auto;
  width: 46px; height: 46px;
  display: grid;
  place-items: center;
  font-size: 1.3rem;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(94,234,212,0.18), rgba(129,140,248,0.18));
  border: 1px solid rgba(94,234,212,0.3);
}
.fact strong { display: block; font-family: var(--font-display); }
.fact div span { color: var(--muted); font-size: 0.85rem; }

/* ---------- Skills ---------- */
.skills-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}
.skill-card { padding: 26px 24px; }
.skill-card h3 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  margin-bottom: 16px;
  letter-spacing: 0.01em;
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font-size: 0.78rem;
  padding: 6px 13px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.04);
  color: var(--muted);
  transition: color 0.25s ease, border-color 0.25s ease, background 0.25s ease, transform 0.25s ease;
}
.chip:hover {
  color: var(--ink);
  border-color: rgba(94, 234, 212, 0.5);
  background: rgba(94, 234, 212, 0.08);
  transform: translateY(-2px);
}

/* ---------- Timeline / Experience ---------- */
.timeline {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 26px;
  padding-left: 34px;
}
.timeline::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 10px;
  bottom: 10px;
  width: 2px;
  background: linear-gradient(180deg, var(--accent), var(--accent-2) 50%, transparent);
  opacity: 0.55;
}
.timeline-item { position: relative; }
.timeline-dot {
  position: absolute;
  left: -31px;
  top: 26px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--bg);
  border: 3px solid var(--accent);
  box-shadow: 0 0 18px rgba(94, 234, 212, 0.6);
}
.tl-card { padding: clamp(20px, 3vw, 30px); }
.tl-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.tl-co { font-family: var(--font-display); font-weight: 600; color: var(--accent); }
.tl-co em { font-style: normal; color: var(--muted); font-weight: 400; font-size: 0.85em; }
.tl-loc {
  font-size: 0.75rem;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.15);
  color: var(--muted);
}
.tl-date { margin-left: auto; color: var(--muted); font-size: 0.8rem; }
.tl-card h3 { font-family: var(--font-display); font-size: 1.25rem; margin-bottom: 8px; }
.tl-card p { color: var(--muted); font-size: 0.94rem; }
.tl-card p strong { color: var(--ink); }
.tl-card .chips { margin-top: 14px; }

/* ---------- Projects ---------- */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}
.project {
  padding: 26px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow: hidden;
}
.project-icon {
  width: 52px; height: 52px;
  display: grid;
  place-items: center;
  font-size: 1.5rem;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(94,234,212,0.16), rgba(129,140,248,0.2));
  border: 1px solid rgba(129, 140, 248, 0.35);
  transform: translateZ(30px);
}
.project-body h3 { font-family: var(--font-display); font-size: 1.2rem; }
.project-tag {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--accent);
  margin-bottom: 6px;
}
.project-body p { color: var(--muted); font-size: 0.9rem; }
.project-body .chips { margin-top: auto; }

/* ---------- Credentials ---------- */
.cred-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}
.cred { padding: 26px 26px; }
.cred h3 { font-family: var(--font-display); margin-bottom: 14px; font-size: 1.05rem; }
.cred ul { list-style: none; display: flex; flex-direction: column; gap: 9px; }
.cred li {
  color: var(--muted);
  font-size: 0.92rem;
  padding-left: 20px;
  position: relative;
}
.cred li::before {
  content: "▸";
  position: absolute;
  left: 0;
  color: var(--accent);
}

/* ---------- Contact ---------- */
.contact-card {
  padding: clamp(30px, 5vw, 56px);
  text-align: center;
  max-width: 780px;
  margin: 0 auto;
}
.contact-card p { color: var(--muted); max-width: 560px; margin: 0 auto; }
.contact-actions {
  margin: 30px 0 14px;
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}
.contact-note { font-size: 0.78rem; opacity: 0.55; }

/* ---------- Footer ---------- */
.footer {
  border-top: 1px solid rgba(255,255,255,0.07);
  padding: 30px min(5vw, 56px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  font-size: 0.88rem;
  max-width: 1280px;
  margin: 0 auto;
}
.back-top {
  width: 42px; height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.2);
  color: var(--ink);
  text-decoration: none;
  transition: transform 0.25s ease, border-color 0.25s ease;
}
.back-top:hover {
  transform: translateY(-4px);
  border-color: var(--accent);
}

/* ---------- Reveal on scroll ---------- */
.reveal {
  opacity: 0;
  transform: translateY(34px) scale(0.985);
  transition: opacity 0.7s cubic-bezier(0.2, 0.65, 0.3, 1), transform 0.7s cubic-bezier(0.2, 0.65, 0.3, 1);
  transition-delay: calc(var(--d, 0) * 1ms);
}
.reveal.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .skills-grid, .projects-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .about-grid { grid-template-columns: 1fr; }
  .about-side { flex-direction: row; flex-wrap: wrap; }
  .fact { flex: 1 1 220px; }
}
@media (max-width: 720px) {
  .nav-toggle { display: flex; }
  .nav-links {
    position: fixed;
    top: 0; right: 0;
    height: 100vh;
    width: min(78vw, 320px);
    flex-direction: column;
    justify-content: center;
    background: rgba(6, 8, 20, 0.92);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-left: 1px solid rgba(255,255,255,0.08);
    transform: translateX(105%);
    transition: transform 0.35s cubic-bezier(0.2, 0.7, 0.3, 1);
    gap: 26px;
    font-size: 1.05rem;
  }
  .nav-links.open { transform: translateX(0); }
  .skills-grid, .projects-grid, .cred-grid { grid-template-columns: 1fr; }
  .hero-stats { grid-template-columns: repeat(2, 1fr); }
  .tl-date { margin-left: 0; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .logo-cube span, .scroll-hint span, .hero-title .cursor { animation: none; }
  * { transition-duration: 0.01ms !important; }
}
