/* ============================================================
   Abhirup Chandra — Portfolio
   Vanilla CSS. Theming via CSS variables, localStorage-first.
   ============================================================ */

:root {
  --font-display: "Space Grotesk", system-ui, sans-serif;
  --font-body: "Inter", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;

  --max: 1100px;
  --radius: 14px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --grad: linear-gradient(120deg, var(--accent), var(--accent-2));
}

[data-theme="dark"] {
  --bg: #0b0f14;
  --bg-2: #0f151d;
  --surface: #121a24;
  --surface-2: #17212e;
  --border: #223042;
  --text: #e6edf3;
  --text-dim: #94a6b8;
  --accent: #ffb454;
  --accent-2: #39d0c3;
  --accent-soft: rgba(255, 180, 84, 0.12);
  --glow: rgba(255, 180, 84, 0.25);
  --terminal-bg: #0a0e13;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  --c-line-alpha: 0.35;
  --c-dot-alpha: 0.75;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #f7f4ee;
  --bg-2: #f1ece2;
  --surface: #ffffff;
  --surface-2: #faf7f1;
  --border: #e2dbcd;
  --text: #1c2430;
  --text-dim: #5b6878;
  --accent: #c77d1b;
  --accent-2: #0e8f84;
  --accent-soft: rgba(199, 125, 27, 0.10);
  --glow: rgba(199, 125, 27, 0.18);
  --terminal-bg: #131a23;
  --shadow: 0 20px 50px rgba(28, 36, 48, 0.10);
  --c-line-alpha: 0.6;
  --c-dot-alpha: 0.95;
  color-scheme: light;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background 0.35s ease, color 0.35s ease;
}

::selection { background: var(--accent); color: var(--bg); }

h1, h2, h3 { font-family: var(--font-display); line-height: 1.15; }
a { color: inherit; text-decoration: none; }
.accent { color: var(--accent); }

/* ============ NAV ============ */
.nav {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem clamp(1.2rem, 4vw, 3rem);
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid transparent;
  transform: translateY(0);
  transition: transform 0.4s var(--ease), border-color 0.3s, background 0.35s;
}
.nav.scrolled { border-bottom-color: var(--border); }
.nav.hidden { transform: translateY(-110%); }

.nav-logo {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
}
.nav-logo svg { color: var(--accent); }
.nav-logo em { color: var(--accent); font-style: normal; }

.nav-links {
  display: flex;
  align-items: center;
  gap: clamp(0.8rem, 2.4vw, 1.8rem);
  font-size: 0.92rem;
  font-weight: 500;
}
.nav-links a {
  color: var(--text-dim);
  position: relative;
  transition: color 0.25s;
}
.nav-links a::after {
  content: "";
  position: absolute;
  left: 0; right: 100%; bottom: -5px;
  height: 2px;
  background: var(--accent);
  transition: right 0.3s var(--ease);
}
.nav-links a:hover, .nav-links a.active { color: var(--text); }
.nav-links a:hover::after, .nav-links a.active::after { right: 0; }

.nav-cta {
  color: var(--accent) !important;
  border: 1px solid var(--accent);
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  transition: background 0.25s, color 0.25s !important;
}
.nav-cta::after { display: none; }
.nav-cta:hover { background: var(--accent); color: var(--bg) !important; }

.theme-toggle {
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  cursor: pointer;
  transition: color 0.25s, border-color 0.25s, transform 0.25s;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); transform: rotate(15deg); }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: none; }

/* ============ HERO ============ */
.hero {
  position: relative;
  min-height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 6rem 1.5rem 4rem;
  background:
    radial-gradient(ellipse 80% 55% at 50% -10%, var(--accent-soft), transparent 70%),
    var(--bg);
}
#constellation {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.7;
}
[data-theme="light"] #constellation { opacity: 1; }
[data-theme="light"] .hero {
  background:
    radial-gradient(ellipse 70% 50% at 18% -8%, rgba(199, 125, 27, 0.16), transparent 62%),
    radial-gradient(ellipse 60% 45% at 85% 2%, rgba(14, 143, 132, 0.13), transparent 60%),
    linear-gradient(180deg, #fdfaf4, var(--bg));
}
[data-theme="light"] .hero-name {
  background: linear-gradient(100deg, #8a4d0a 10%, var(--accent) 55%, var(--accent-2) 100%);
  -webkit-background-clip: text;
  background-clip: text;
}
.hero-inner { position: relative; max-width: 820px; }

.hero-kicker {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-2);
  margin-bottom: 1.2rem;
}
.hero-name {
  font-size: clamp(2.8rem, 8vw, 5.2rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(100deg, var(--text) 30%, var(--accent) 85%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 1.1rem;
}
.hero-role {
  font-size: clamp(1.05rem, 2.2vw, 1.3rem);
  color: var(--text-dim);
  max-width: 640px;
  margin: 0 auto 2.2rem;
}

.searchbar {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  min-width: min(560px, 90vw);
  padding: 0.85rem 1.1rem;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 0 0 0 var(--glow), var(--shadow);
  font-family: var(--font-mono);
  font-size: 0.95rem;
  text-align: left;
  color: var(--text-dim);
  animation: searchGlow 4s ease-in-out infinite;
}
.searchbar svg { color: var(--accent); flex: none; }
.searchbar-text { color: var(--text); white-space: nowrap; overflow: hidden; }
.searchbar-kbd {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.1rem 0.45rem;
}
.caret {
  width: 2px; height: 1.15em;
  background: var(--accent);
  animation: blink 1.05s step-end infinite;
}
@keyframes blink { 50% { opacity: 0; } }
@keyframes searchGlow {
  0%, 100% { box-shadow: 0 0 0 0 var(--glow), var(--shadow); }
  50% { box-shadow: 0 0 34px 2px var(--glow), var(--shadow); }
}

.hero-ctas {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 2.4rem;
  flex-wrap: wrap;
}

.btn {
  display: inline-block;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.8rem 1.7rem;
  border-radius: 10px;
  transition: transform 0.25s var(--ease), box-shadow 0.25s, background 0.25s, color 0.25s, border-color 0.25s;
}
.btn-primary {
  background: var(--grad);
  color: #10141a;
  box-shadow: 0 8px 24px var(--glow);
}
[data-theme="light"] .btn-primary { color: #fff; }
.btn-primary:hover { transform: translateY(-3px); box-shadow: 0 14px 34px var(--glow); }
.btn-ghost {
  border: 1px solid var(--border);
  color: var(--text);
  background: transparent;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-3px); }
.btn-lg { font-size: 1.05rem; padding: 1rem 2.2rem; }

.scroll-hint {
  position: absolute;
  bottom: 2rem;
  left: 50%;
  translate: -50% 0;
  width: 26px; height: 42px;
  border: 2px solid var(--border);
  border-radius: 14px;
  display: flex;
  justify-content: center;
}
.scroll-hint span {
  width: 4px; height: 8px;
  margin-top: 7px;
  border-radius: 2px;
  background: var(--accent);
  animation: scrollDrop 1.8s ease-in-out infinite;
}
@keyframes scrollDrop {
  0% { transform: translateY(0); opacity: 1; }
  70% { transform: translateY(14px); opacity: 0; }
  100% { transform: translateY(0); opacity: 0; }
}

/* Hero entrance */
.anim-up {
  opacity: 0;
  transform: translateY(26px);
  animation: heroUp 0.9s var(--ease) forwards;
  animation-delay: calc(var(--d, 0) * 0.13s + 0.1s);
}
@keyframes heroUp { to { opacity: 1; transform: none; } }

/* ============ STATS ============ */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border);
  border-block: 1px solid var(--border);
}
.stat {
  background: var(--bg-2);
  text-align: center;
  padding: 2.6rem 1rem;
  transition: background 0.3s;
}
.stat:hover { background: var(--surface); }
.stat-num {
  display: block;
  font-family: var(--font-display);
  font-size: clamp(1.9rem, 4vw, 2.7rem);
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.stat-label {
  font-size: 0.88rem;
  color: var(--text-dim);
  letter-spacing: 0.04em;
}

/* ============ SECTIONS ============ */
.section {
  max-width: var(--max);
  margin: 0 auto;
  padding: clamp(4.5rem, 9vw, 7.5rem) 1.5rem 0;
}
.section-title {
  display: flex;
  align-items: baseline;
  gap: 0.9rem;
  font-size: clamp(1.7rem, 3.6vw, 2.4rem);
  margin-bottom: clamp(2rem, 4vw, 3.2rem);
}
.section-index {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--accent);
}
.section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--accent) 50%, transparent),
    color-mix(in srgb, var(--accent-2) 25%, transparent),
    var(--border));
  translate: 0 -0.35em;
}

/* Scroll reveal */
.reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.8s var(--ease), transform 0.8s var(--ease);
  transition-delay: calc(var(--d, 0) * 0.12s);
}
.reveal.visible { opacity: 1; transform: none; }

/* ============ ABOUT ============ */
.about-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: clamp(1.5rem, 4vw, 3.5rem);
  align-items: start;
}
.about-text p + p { margin-top: 1.1rem; }
.about-text { color: var(--text-dim); font-size: 1.02rem; }
.about-text strong { color: var(--text); font-weight: 600; }

.about-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.6rem;
  box-shadow: var(--shadow);
}
.about-card ul { list-style: none; }
.about-card li {
  padding: 0.75rem 0;
  font-size: 0.93rem;
  border-bottom: 1px dashed var(--border);
}
.about-card li:last-child { border-bottom: none; }
.about-card li span {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent-2);
  margin-bottom: 0.15rem;
}

/* ============ TIMELINE ============ */
.timeline {
  position: relative;
  padding-left: 2rem;
}
.timeline::before {
  content: "";
  position: absolute;
  left: 6px; top: 6px; bottom: 6px;
  width: 2px;
  background: linear-gradient(var(--accent), var(--accent-2), var(--border));
  border-radius: 2px;
}
.timeline-item { position: relative; padding-bottom: 3rem; }
.timeline-item:last-child { padding-bottom: 0.5rem; }
.timeline-dot {
  position: absolute;
  left: -2rem; top: 7px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--bg);
  border: 3px solid var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.timeline-date {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent-2);
  letter-spacing: 0.06em;
  margin-bottom: 0.3rem;
}
.timeline-item h3 { font-size: 1.25rem; margin-bottom: 0.15rem; }
.timeline-sub {
  font-size: 0.9rem;
  color: var(--text-dim);
  font-style: italic;
  margin-bottom: 0.7rem;
}
.timeline-item > p:not(.timeline-date):not(.timeline-sub) {
  color: var(--text-dim);
  max-width: 680px;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.9rem;
}
.tags span {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  padding: 0.22rem 0.65rem;
  border-radius: 999px;
}

/* ============ FEATURED WORK ============ */
.feature {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: clamp(1.5rem, 4vw, 3rem);
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 6px);
  padding: clamp(1.5rem, 4vw, 2.8rem);
  margin-bottom: 2rem;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.feature::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(600px 300px at var(--mx, 20%) var(--my, 0%), var(--accent-soft), transparent 60%);
  opacity: 0;
  transition: opacity 0.5s;
  pointer-events: none;
}
.feature:hover::before { opacity: 1; }
.feature-flip .feature-body { order: 2; }
.feature-flip .feature-visual { order: 1; }

.feature-kicker {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent-2);
  margin-bottom: 0.6rem;
}
.feature h3 { font-size: clamp(1.3rem, 2.6vw, 1.7rem); margin-bottom: 0.8rem; }
.feature-body > p { color: var(--text-dim); }
.feature-points {
  list-style: none;
  margin-top: 1rem;
}
.feature-points li {
  position: relative;
  padding: 0.32rem 0 0.32rem 1.5rem;
  font-size: 0.94rem;
  color: var(--text-dim);
}
.feature-points li::before {
  content: "▸";
  position: absolute;
  left: 0.2rem;
  color: var(--accent);
}

/* Terminal mock */
.terminal {
  background: var(--terminal-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
  transform: rotate(0.6deg);
  transition: transform 0.4s var(--ease);
}
.feature:hover .terminal { transform: rotate(0deg) translateY(-4px); }
.feature-flip .terminal { transform: rotate(-0.6deg); }
.terminal-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}
.terminal-bar i {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #3a4656;
}
.terminal-bar i:first-child { background: #ff5f56; }
.terminal-bar i:nth-child(2) { background: #ffbd2e; }
.terminal-bar i:nth-child(3) { background: #27c93f; }
.terminal-bar b {
  margin-left: 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 400;
  color: #6b7d92;
}
.terminal pre {
  padding: 1.1rem 1.2rem;
  overflow-x: auto;
}
.terminal code {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.75;
  color: #c9d6e3;
  white-space: pre;
}
.t-dim { color: #5c7089; }
.t-acc { color: #ffb454; }
.t-ok { color: #43d9ad; }

/* ============ PROJECTS ============ */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.3rem;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  transition: transform 0.35s var(--ease), border-color 0.35s, box-shadow 0.35s;
}
.card:hover {
  transform: translateY(-6px);
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
  box-shadow: 0 18px 40px var(--glow);
}
.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.9rem;
}
.card-icon { font-size: 1.5rem; }
.card-type {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
}
.card h3 { font-size: 1.15rem; margin-bottom: 0.45rem; }
.card p { font-size: 0.9rem; color: var(--text-dim); flex: 1; }
.card .tags { margin-top: 1rem; }

/* ============ SKILLS ============ */
.skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.3rem;
}
.skill-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem 1.5rem;
}
.skill-group h3 {
  font-size: 0.95rem;
  margin-bottom: 0.9rem;
  color: var(--accent-2);
}
.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chips span {
  font-size: 0.83rem;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  transition: border-color 0.25s, color 0.25s, transform 0.25s;
}
.chips span:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-2px);
}

/* ============ CONTACT ============ */
.contact { padding-bottom: clamp(4.5rem, 9vw, 7rem); }
.contact-inner {
  text-align: center;
  background:
    radial-gradient(ellipse 70% 90% at 30% 110%, var(--accent-soft), transparent 70%),
    radial-gradient(ellipse 55% 70% at 85% 115%, color-mix(in srgb, var(--accent-2) 10%, transparent), transparent 70%),
    var(--surface);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 8px);
  padding: clamp(3rem, 7vw, 5rem) 1.5rem;
  box-shadow: var(--shadow);
}
.contact h2 { font-size: clamp(1.9rem, 4.6vw, 3rem); margin-bottom: 1rem; }
.contact-sub {
  color: var(--text-dim);
  max-width: 480px;
  margin: 0 auto 2.2rem;
}
.contact-links {
  margin-top: 1.6rem;
  display: flex;
  gap: 0.8rem;
  justify-content: center;
  color: var(--text-dim);
  font-size: 0.95rem;
}
.contact-links a {
  color: var(--text-dim);
  border-bottom: 1px solid transparent;
  transition: color 0.25s, border-color 0.25s;
}
.contact-links a:hover { color: var(--accent); border-color: var(--accent); }

/* ============ FOOTER ============ */
.footer {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  max-width: var(--max);
  margin: 0 auto;
  padding: 1.6rem 1.5rem;
  border-top: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.85rem;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 900px) {
  .about-grid, .feature { grid-template-columns: 1fr; }
  .feature-flip .feature-body { order: 1; }
  .feature-flip .feature-visual { order: 2; }
  .projects-grid { grid-template-columns: repeat(2, 1fr); }
  .stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .nav-links a:not(.nav-cta) { display: none; }
  .projects-grid { grid-template-columns: 1fr; }
  .searchbar { min-width: 0; width: 100%; font-size: 0.82rem; }
  .searchbar-kbd { display: none; }
}

/* ============ REDUCED MOTION ============ */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .anim-up { animation: none; opacity: 1; transform: none; }
  .reveal { transition: none; opacity: 1; transform: none; }
  .caret, .scroll-hint span, .searchbar { animation: none; }
  #constellation { display: none; }
  * { transition-duration: 0.01ms !important; }
}
