/* ============================================================
   Karan Chawla - Portfolio
   Single dark identity, Apple-style scroll flow.
   ============================================================ */

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

:root {
  --bg: #0B0C10;
  --bg-alt: #121319;
  --surface: #16181F;
  --surface-hover: #1C1F29;
  --line: rgba(244,243,239,0.09);
  --line-strong: rgba(244,243,239,0.18);
  --ink: #F4F3EF;
  --muted: #9A9DAC;
  --muted-2: #6E7180;
  --accent: #5B8CFF;
  --accent-ink: #06101F;
  --accent-soft: rgba(91,140,255,0.14);
  --warn: #FFB454;
  --mono: 'IBM Plex Mono', 'SFMono-Regular', Menlo, monospace;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --ease: cubic-bezier(.16,1,.3,1);
  --nav-h: 76px;
  --nav-h-shrunk: 60px;
  --card-shadow: none;
  --hero-orbs: block;
  --card-bar-opacity: 0;
}

/* ── THEME: Daylight (light, editorial) ── */
[data-theme="daylight"] {
  --bg: #F6F6F3;
  --bg-alt: #EDEDE8;
  --surface: #FFFFFF;
  --surface-hover: #F7F7F4;
  --line: rgba(20,20,22,0.10);
  --line-strong: rgba(20,20,22,0.20);
  --ink: #16171B;
  --muted: #55586A;
  --muted-2: #8A8D9C;
  --accent: #2451D6;
  --accent-ink: #FFFFFF;
  --accent-soft: rgba(36,81,214,0.10);
  --warn: #B45309;
  --card-shadow: 0 1px 2px rgba(20,20,22,0.04), 0 14px 30px -18px rgba(20,20,22,0.18);
  --hero-orbs: none;
  --card-bar-opacity: 0;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

html { scroll-behavior: smooth; background: var(--bg); }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: inherit; }
img { max-width: 100%; display: block; }

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

/* ── NAV ── */
nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: var(--nav-h);
  padding: 0 clamp(20px, 5vw, 60px);
  background: color-mix(in srgb, var(--bg) 50%, transparent);
  backdrop-filter: blur(0px);
  -webkit-backdrop-filter: blur(0px);
  border-bottom: 1px solid transparent;
  transition: height 0.4s var(--ease), background 0.4s var(--ease), border-color 0.4s var(--ease), backdrop-filter 0.4s var(--ease);
}

nav.scrolled {
  height: var(--nav-h-shrunk);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--line);
}

.nav-logo {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-logo-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.nav-links { display: flex; gap: clamp(18px, 2.4vw, 34px); list-style: none; }

.nav-links a {
  font-size: 13.5px;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s;
  letter-spacing: -0.005em;
}

.nav-links a:hover, .nav-links a.current { color: var(--ink); }

.nav-cta {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  padding: 8px 18px;
  border-radius: 30px;
  transition: border-color 0.2s, background 0.2s, transform 0.2s;
  display: none;
}

.nav-cta:hover { border-color: var(--accent); background: var(--surface-hover); transform: translateY(-1px); }

@media (min-width: 640px) { .nav-cta { display: inline-block; } }

.nav-right { display: flex; align-items: center; gap: 14px; }

.theme-toggle {
  appearance: none;
  width: 38px; height: 38px;
  flex: none;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.2s;
}
.theme-toggle:hover { border-color: var(--accent); background: var(--surface-hover); transform: translateY(-1px); }
.theme-toggle svg { width: 17px; height: 17px; }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
[data-theme="daylight"] .theme-toggle .icon-sun { display: block; }
[data-theme="daylight"] .theme-toggle .icon-moon { display: none; }

/* ── SHARED ── */
.wrap { max-width: 1180px; margin: 0 auto; padding-left: clamp(20px, 5vw, 60px); padding-right: clamp(20px, 5vw, 60px); }

.chapter { padding-block: clamp(80px, 12vw, 160px); position: relative; }
.chapter.alt { background: var(--bg-alt); }
.chapter-border { border-top: 1px solid var(--line); }

.eyebrow {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--accent);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.eyebrow::before {
  content: '';
  width: 16px; height: 1px;
  background: var(--accent);
}

.chapter-title {
  font-size: clamp(30px, 4.4vw, 54px);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.1;
  text-wrap: balance;
  max-width: 16ch;
}

.chapter-sub {
  font-size: clamp(15px, 1.4vw, 18px);
  color: var(--muted);
  max-width: 46ch;
  margin-top: 18px;
  font-weight: 300;
}

/* reveal */
.reveal {
  opacity: 0;
  transform: translateY(36px);
  transition: opacity 0.9s var(--ease), transform 0.9s var(--ease);
  will-change: transform, opacity;
}
.reveal.visible { opacity: 1; transform: translateY(0); }
.reveal-fade { opacity: 0; transition: opacity 1s var(--ease); }
.reveal-fade.visible { opacity: 1; }

/* ── HERO ── */
.hero {
  min-height: 92vh;
  display: flex;
  align-items: center;
  padding-top: calc(var(--nav-h) + 24px);
  position: relative;
  overflow: hidden;
}

.hero-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  display: var(--hero-orbs);
}

.hero-bg span {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.5;
}

.orb-1 { width: 560px; height: 560px; top: -180px; right: -120px; background: radial-gradient(circle, color-mix(in srgb, var(--accent) 35%, transparent), transparent 70%); animation: drift1 22s ease-in-out infinite; }
.orb-2 { width: 420px; height: 420px; bottom: -160px; left: -100px; background: radial-gradient(circle, color-mix(in srgb, var(--accent) 16%, transparent), transparent 70%); animation: drift2 26s ease-in-out infinite; }

@keyframes drift1 { 0%,100% { transform: translate(0,0); } 50% { transform: translate(-40px, 30px); } }
@keyframes drift2 { 0%,100% { transform: translate(0,0); } 50% { transform: translate(30px, -30px); } }

.hero-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1.25fr 0.75fr;
  gap: clamp(30px, 6vw, 70px);
  align-items: center;
  width: 100%;
}

.hero-name {
  font-size: clamp(46px, 6.8vw, 88px);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.02;
  margin-bottom: 22px;
}

.hero-name .accent-word { color: var(--accent); }

.hero-tagline {
  font-size: clamp(17px, 1.9vw, 22px);
  color: var(--muted);
  font-weight: 300;
  max-width: 540px;
  line-height: 1.55;
  margin-bottom: 40px;
}

.hero-cta { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; margin-bottom: 46px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 13px 26px;
  border-radius: 30px;
  font-size: 14.5px;
  font-weight: 600;
  text-decoration: none;
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease), background 0.25s, border-color 0.25s, color 0.25s;
  cursor: pointer;
  border: 1px solid transparent;
  white-space: nowrap;
}

.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 14px 34px -8px rgba(91,140,255,0.55); }

.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-2px); }

.btn-sm { padding: 8px 16px; font-size: 12.5px; border-radius: 20px; }

.hero-meta {
  display: flex;
  gap: 28px;
  flex-wrap: wrap;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted-2);
  letter-spacing: 0.02em;
}
.hero-meta span { display: flex; align-items: center; gap: 8px; }
.hero-meta b { color: var(--muted); font-weight: 500; }

.hero-photo-wrap {
  position: relative;
  z-index: 1;
}

.hero-photo {
  width: 100%;
  aspect-ratio: 4/5;
  border-radius: 28px;
  object-fit: cover;
  object-position: 50% 20%;
  border: 1px solid var(--line-strong);
  box-shadow: 0 40px 90px -30px rgba(0,0,0,0.6);
}

.scroll-cue {
  position: absolute;
  bottom: 36px;
  left: clamp(20px, 5vw, 60px);
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted-2);
  letter-spacing: 0.08em;
  z-index: 1;
}

.scroll-cue-line { width: 1px; height: 34px; background: linear-gradient(to bottom, var(--muted-2), transparent); position: relative; overflow: hidden; }
.scroll-cue-line::after { content: ''; position: absolute; top: -100%; left: 0; width: 100%; height: 100%; background: var(--accent); animation: scrollDown 2.2s ease-in-out infinite; }
@keyframes scrollDown { 0% { top: -100%; } 100% { top: 100%; } }

/* ── STATS ── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 2px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 20px;
  overflow: hidden;
}

.stat-cell {
  background: var(--bg-alt);
  padding: clamp(28px, 4vw, 44px) clamp(18px, 3vw, 28px);
  text-align: left;
  box-shadow: var(--card-shadow);
}

.stat-num {
  font-size: clamp(34px, 4.6vw, 56px);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: baseline;
  gap: 2px;
}
.stat-num .suffix { color: var(--accent); font-size: 0.55em; font-weight: 700; }

.stat-label { font-size: 13px; color: var(--muted); margin-top: 8px; max-width: 20ch; }

/* ── ABOUT ── */
.about-grid { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(40px,6vw,90px); align-items: start; }
.about-text p { color: var(--muted); font-size: 17px; font-weight: 300; line-height: 1.85; margin-bottom: 22px; }
.about-text p strong { color: var(--ink); font-weight: 600; }

.about-facts { display: flex; flex-direction: column; gap: 0; }
.about-fact { display: flex; justify-content: space-between; gap: 20px; padding: 18px 0; border-bottom: 1px solid var(--line); font-size: 14.5px; }
.about-fact:first-child { padding-top: 0; }
.about-fact-label { color: var(--muted-2); font-family: var(--mono); font-size: 11.5px; letter-spacing: 0.06em; text-transform: uppercase; padding-top: 3px; }
.about-fact-value { color: var(--ink); text-align: right; max-width: 60%; }
.about-fact-value a { color: var(--accent); text-decoration: none; }
.about-fact-value a:hover { text-decoration: underline; }

/* ── EXPERIENCE ── */
.exp-entry {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: clamp(30px, 5vw, 64px);
  padding-block: 50px;
  border-top: 1px solid var(--line);
}
.exp-entry:last-child { border-bottom: 1px solid var(--line); }

.exp-sticky { position: sticky; top: calc(var(--nav-h-shrunk) + 40px); align-self: start; height: fit-content; }

.exp-date { font-family: var(--mono); font-size: 12px; color: var(--muted-2); letter-spacing: 0.04em; margin-bottom: 10px; }
.exp-company { font-size: 15px; color: var(--accent); font-weight: 600; margin-bottom: 4px; }
.exp-location { font-size: 13px; color: var(--muted); }

.exp-title { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; margin-bottom: 24px; }

.exp-bullets { list-style: none; display: flex; flex-direction: column; gap: 15px; }
.exp-bullets li { font-size: 15.5px; color: var(--muted); padding-left: 22px; position: relative; line-height: 1.65; }
.exp-bullets li::before { content: ''; position: absolute; left: 0; top: 9px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.exp-bullets li b { color: var(--ink); font-weight: 600; }

/* ── EDUCATION ── */
.edu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; background: var(--line); border: 1px solid var(--line); border-radius: 20px; overflow: hidden; }
.edu-cell { background: var(--bg-alt); padding: 34px 32px; box-shadow: var(--card-shadow); }
.edu-school { font-size: 18px; font-weight: 700; margin-bottom: 6px; }
.edu-degree { font-size: 14.5px; color: var(--muted); margin-bottom: 14px; }
.edu-meta { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 11.5px; color: var(--muted-2); letter-spacing: 0.04em; }
.edu-note { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 13.5px; color: var(--muted); line-height: 1.6; }

/* ── SKILLS ── */
.skills-wrap { display: flex; flex-direction: column; gap: 28px; }
.skill-row { display: grid; grid-template-columns: 180px 1fr; gap: 24px; align-items: baseline; padding-bottom: 24px; border-bottom: 1px solid var(--line); }
.skill-row:last-child { border-bottom: none; }
.skill-cat { font-family: var(--mono); font-size: 12px; color: var(--muted-2); letter-spacing: 0.06em; text-transform: uppercase; }
.skill-tags { display: flex; flex-wrap: wrap; gap: 9px; }
.skill-tag {
  font-size: 13.5px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 7px 15px;
  border-radius: 20px;
  transition: color 0.2s, border-color 0.2s, transform 0.2s, background 0.2s;
}
.skill-tag:hover { color: var(--ink); border-color: var(--accent); background: var(--surface-hover); transform: translateY(-2px); }

/* ── PROJECTS CAROUSEL ── */
.carousel-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 36px; flex-wrap: wrap; }
.carousel-nav { display: flex; gap: 10px; }
.carousel-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
  font-size: 16px;
}
.carousel-btn:hover { border-color: var(--accent); background: var(--surface-hover); }
.carousel-btn:active { transform: scale(0.94); }
.carousel-btn:disabled { opacity: 0.3; cursor: default; }
.carousel-btn:disabled:hover { border-color: var(--line-strong); background: var(--surface); }

.carousel-track {
  display: flex;
  gap: 20px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  padding-bottom: 8px;
  margin: 0 calc(-1 * clamp(20px, 5vw, 60px));
  padding-left: clamp(20px, 5vw, 60px);
  padding-right: clamp(20px, 5vw, 60px);
  scrollbar-width: none;
}
.carousel-track::-webkit-scrollbar { display: none; }

.project-card {
  scroll-snap-align: start;
  flex: 0 0 clamp(280px, 34vw, 380px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  box-shadow: var(--card-shadow);
  transition: border-color 0.25s, transform 0.25s, background 0.25s, box-shadow 0.25s;
}
.project-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--accent);
  opacity: var(--card-bar-opacity);
  transition: opacity 0.25s;
}
.project-card:hover { border-color: var(--line-strong); background: var(--surface-hover); transform: translateY(-4px); }
.project-card:hover::before { opacity: 1; }

.project-type { font-family: var(--mono); font-size: 10.5px; color: var(--accent); letter-spacing: 0.1em; text-transform: uppercase; margin-bottom: 16px; }
.project-name { font-size: 19px; font-weight: 700; margin-bottom: 12px; line-height: 1.3; letter-spacing: -0.01em; }
.project-desc { font-size: 13.5px; color: var(--muted); line-height: 1.65; margin-bottom: 22px; flex: 1; }
.project-links { display: flex; gap: 10px; flex-wrap: wrap; margin-top: auto; }

.project-link {
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 15px;
  border-radius: 20px;
  border: 1px solid var(--line-strong);
  color: var(--muted);
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}
.project-link:hover { border-color: var(--accent); color: var(--ink); }
.project-link.request { border-color: var(--accent); color: var(--accent); }
.project-link.request:hover { background: var(--accent); color: var(--accent-ink); }
.project-link.locked { opacity: 0.5; cursor: default; }
.project-link.locked:hover { border-color: var(--line-strong); color: var(--muted); }

/* ── WRITING ── */
.articles-list { display: flex; flex-direction: column; }
.article-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 24px 4px; border-bottom: 1px solid var(--line);
  text-decoration: none; color: var(--ink);
  transition: color 0.2s, padding-left 0.25s var(--ease), border-color 0.2s;
  gap: 22px;
}
.article-row:first-child { border-top: 1px solid var(--line); }
.article-row:hover { color: var(--accent); padding-left: 14px; border-color: var(--line-strong); }
.article-row:hover .article-arrow { transform: translateX(5px); color: var(--accent); }
.article-title { font-size: 16px; font-weight: 500; flex: 1; letter-spacing: -0.005em; }
.article-tag { font-family: var(--mono); font-size: 10.5px; color: var(--muted-2); letter-spacing: 0.07em; white-space: nowrap; text-transform: uppercase; }
.article-arrow { color: var(--muted-2); transition: transform 0.25s var(--ease), color 0.2s; font-size: 17px; }

/* ── CONTACT ── */
.contact-chapter { text-align: center; }
.contact-headline {
  font-size: clamp(34px, 6vw, 68px);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.08;
  margin-bottom: 22px;
  max-width: 16ch;
  margin-inline: auto;
}
.contact-sub { color: var(--muted); font-size: 17px; font-weight: 300; margin-bottom: 44px; max-width: 48ch; margin-inline: auto; }
.contact-links { display: flex; justify-content: center; gap: 14px; flex-wrap: wrap; }

/* ── FOOTER ── */
footer {
  border-top: 1px solid var(--line);
  padding: 30px clamp(20px, 5vw, 60px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted-2);
  font-size: 12.5px;
  font-family: var(--mono);
  flex-wrap: wrap;
  gap: 10px;
}

/* ── TOAST ── */
.site-toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 12px);
  z-index: 300;
  background: var(--ink);
  color: var(--bg);
  font-family: var(--mono);
  font-size: 12.5px;
  padding: 12px 20px;
  border-radius: 30px;
  box-shadow: 0 20px 40px -14px rgba(0,0,0,0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
  max-width: calc(100vw - 40px);
  text-align: center;
}
.site-toast.visible { opacity: 1; transform: translate(-50%, 0); }

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  .hero-grid { grid-template-columns: 1fr; }
  .hero-photo-wrap { order: -1; max-width: 260px; margin: 0 auto 10px; }
  .stats-row { grid-template-columns: 1fr 1fr; }
  .about-grid { grid-template-columns: 1fr; gap: 40px; }
  .exp-entry { grid-template-columns: 1fr; gap: 18px; }
  .exp-sticky { position: static; }
  .edu-grid { grid-template-columns: 1fr; }
  .skill-row { grid-template-columns: 1fr; gap: 10px; }
}

@media (max-width: 640px) {
  .nav-links { display: none; }
  .hero { min-height: auto; padding-bottom: 60px; }
  .scroll-cue { display: none; }
  .stats-row { grid-template-columns: 1fr; }
  footer { flex-direction: column; text-align: center; }
}
