/* ============================================================
   Ayush Agarwal · portfolio
   Vanilla CSS. Light/dark themes via [data-theme] on <html>.
   ============================================================ */

/* ---------- Design tokens ---------- */
:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono",
    Menlo, Consolas, "Liberation Mono", monospace;
  --radius: 10px;
  --radius-sm: 6px;
  --maxw: 1080px;
  --maxw-prose: 760px;
}

:root[data-theme="light"] {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --text: #171c24;
  --muted: #5b6572;
  --border: #e2e6ec;
  --accent: #2158c9;
  --accent-contrast: #ffffff;
  --accent-soft: rgba(33, 88, 201, 0.09);
  --good: #15803d;
  --bad: #c62828;
  --warn: #b45309;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 4px 16px rgba(16, 24, 40, 0.06);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0d1117;
  --surface: #151b23;
  --surface-2: #1d2530;
  --text: #e6ebf2;
  --muted: #94a1b0;
  --border: #2a323d;
  --accent: #6ca6ff;
  --accent-contrast: #0b1524;
  --accent-soft: rgba(108, 166, 255, 0.13);
  --good: #4ade80;
  --bad: #f87171;
  --warn: #fbbf24;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 20px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  font-size: 16.5px;
  -webkit-font-smoothing: antialiased;
  transition: background 0.25s ease, color 0.25s ease;
}

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

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

code, .mono { font-family: var(--font-mono); }

code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1em 0.35em;
  font-size: 0.85em;
}

::selection { background: var(--accent-soft); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.container {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.site-header nav {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.logo {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
  white-space: nowrap;
}
.logo:hover { text-decoration: none; color: var(--accent); }
.logo .accent { color: var(--accent); }

.nav-links {
  display: flex;
  list-style: none;
  gap: 4px;
  margin-left: auto;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav-links::-webkit-scrollbar { display: none; }

.nav-links a {
  color: var(--muted);
  font-size: 0.9rem;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}
.nav-links a:hover {
  color: var(--text);
  background: var(--surface-2);
  text-decoration: none;
}

.theme-toggle {
  flex-shrink: 0;
  margin-left: 8px;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted);
  cursor: pointer;
}
.theme-toggle:hover { color: var(--text); background: var(--surface-2); }
.theme-toggle svg { width: 17px; height: 17px; }
:root[data-theme="light"] .icon-sun { display: none; }
:root[data-theme="dark"] .icon-moon { display: none; }

/* ---------- Sections ---------- */
section { padding: 72px 0; }
section + section { border-top: 1px solid var(--border); }

.kicker {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
}

h2.section-title {
  font-size: 1.7rem;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.section-sub {
  color: var(--muted);
  max-width: 62ch;
  margin-bottom: 36px;
}

/* ---------- Hero ---------- */
.hero { padding: 96px 0 84px; border-top: none; }

.hero h1 {
  font-size: clamp(2.4rem, 6vw, 3.6rem);
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin: 10px 0 14px;
}

.hero .role {
  font-family: var(--font-mono);
  font-size: clamp(1rem, 2.4vw, 1.2rem);
  color: var(--muted);
  margin-bottom: 22px;
}
.hero .role strong { color: var(--text); font-weight: 600; }

.hero .bio {
  max-width: 62ch;
  color: var(--muted);
  margin-bottom: 30px;
}
.hero .bio strong { color: var(--text); font-weight: 600; }

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.social-row {
  display: inline-flex;
  gap: 6px;
  margin-left: 6px;
}
.social-row a {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted);
}
.social-row a:hover { color: var(--accent); background: var(--surface-2); text-decoration: none; }
.social-row svg { width: 18px; height: 18px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 0.92rem;
  font-weight: 550;
  cursor: pointer;
  background: var(--surface);
  color: var(--text);
  transition: background 0.15s ease, border-color 0.15s ease;
}
.btn:hover { text-decoration: none; background: var(--surface-2); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}
.btn-primary:hover {
  background: color-mix(in srgb, var(--accent) 88%, var(--text));
}
.btn svg { width: 15px; height: 15px; }

/* ---------- Experience ---------- */
.xp-item {
  position: relative;
  padding: 0 0 36px 28px;
  border-left: 2px solid var(--border);
}
.xp-item:last-child { padding-bottom: 4px; }
.xp-item::before {
  content: "";
  position: absolute;
  left: -7px;
  top: 6px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  border: 2.5px solid var(--bg);
}

.xp-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 14px;
  margin-bottom: 4px;
}
.xp-head h3 { font-size: 1.12rem; letter-spacing: -0.01em; }
.xp-company { color: var(--accent); font-weight: 550; }
.xp-date {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
}

.xp-item ul { margin: 10px 0 0 18px; color: var(--muted); }
.xp-item li { margin-bottom: 8px; }
.xp-item li strong { color: var(--text); font-weight: 550; }

/* ---------- Project cards ---------- */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 20px;
}

/* extra cards revealed by the "show more" toggle */
.projects-grid .project-card.extra { display: none; }
.projects-grid.show-all .project-card.extra { display: flex; }

.projects-more {
  display: flex;
  justify-content: center;
  margin-top: 26px;
}
.projects-more .btn { min-width: 220px; justify-content: center; }
.projects-more svg {
  width: 14px; height: 14px;
  transition: transform 0.2s ease;
}
.projects-more[data-expanded="true"] svg { transform: rotate(180deg); }

.project-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px;
  color: var(--text);
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.project-card:hover {
  text-decoration: none;
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}
.project-card .tags {
  gap: 6px;
  margin-bottom: 14px;
}

.tags span {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 2px 9px;
  white-space: nowrap;
}

.project-card h3 { font-size: 1.18rem; letter-spacing: -0.01em; margin-bottom: 8px; }
.project-card p { color: var(--muted); font-size: 0.94rem; flex-grow: 1; }

.card-cta {
  margin-top: 18px;
  font-size: 0.9rem;
  font-weight: 550;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* ---------- Skills ---------- */
.skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 20px;
}
.skill-cat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
}
.skill-cat h3 {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 14px;
}
.skill-cat .tags { display: flex; flex-wrap: wrap; gap: 7px; }

/* ---------- Education / achievements ---------- */
.edu-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 20px;
}
@media (max-width: 760px) { .edu-grid { grid-template-columns: 1fr; } }

.edu-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px;
}
.edu-card h3 { font-size: 1.1rem; margin-bottom: 4px; }
.edu-card .edu-meta {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 12px;
}
.edu-card p { color: var(--muted); font-size: 0.93rem; }
.edu-card ul { margin: 6px 0 0 18px; color: var(--muted); font-size: 0.95rem; }
.edu-card li { margin-bottom: 9px; }
.edu-card li strong { color: var(--text); font-weight: 550; }

/* ---------- Contact ---------- */
.contact-inner { text-align: center; max-width: 560px; margin: 0 auto; }
.contact-inner .section-sub { margin: 0 auto 28px; }
.contact-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 28px 0;
  color: var(--muted);
  font-size: 0.85rem;
}
.site-footer .container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  justify-content: space-between;
}

/* ============================================================
   Project deep-dive pages
   ============================================================ */

.page-hero { padding: 64px 0 40px; }

.back-link {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 26px;
}
.back-link:hover { color: var(--accent); text-decoration: none; }

.page-hero h1 {
  font-size: clamp(1.9rem, 5vw, 2.7rem);
  letter-spacing: -0.025em;
  line-height: 1.15;
  margin: 12px 0 14px;
}

.page-hero .lede { color: var(--muted); max-width: 68ch; font-size: 1.05rem; }

.page-hero .meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 22px;
}

.repo-note {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
}

/* ---------- Prose sections ---------- */
.prose-section { padding: 44px 0; }
.prose-section + .prose-section { border-top: 1px solid var(--border); }

.prose { max-width: var(--maxw-prose); }
.prose h2 { font-size: 1.45rem; letter-spacing: -0.02em; margin-bottom: 16px; }
.prose h3 { font-size: 1.08rem; margin: 26px 0 10px; }
.prose p { color: var(--muted); margin-bottom: 14px; }
.prose p strong, .prose li strong { color: var(--text); font-weight: 600; }
.prose ul, .prose ol { margin: 0 0 14px 20px; color: var(--muted); }
.prose li { margin-bottom: 9px; }

.prose pre {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  overflow-x: auto;
  font-size: 0.83rem;
  line-height: 1.6;
  margin-bottom: 14px;
}
.prose pre code { background: none; border: none; padding: 0; font-size: inherit; }

.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  margin-bottom: 14px;
}
.prose th, .prose td {
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
}
.prose th {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}
.prose td { color: var(--muted); }
.prose td:first-child { color: var(--text); font-weight: 550; }

.callout {
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin: 18px 0;
  color: var(--muted);
  font-size: 0.94rem;
}
.callout strong { color: var(--text); }

/* ---------- Demo panel ---------- */
.demo {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  margin: 8px 0;
}

.demo-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.demo-head .demo-title {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--muted);
  margin-right: auto;
}
.demo-head .demo-title::before { content: "▸ "; color: var(--accent); }

.demo-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.demo-btn {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 7px 13px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s ease;
}
.demo-btn:hover { border-color: var(--accent); color: var(--accent); }
.demo-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}
.demo-btn.ghost { border-style: dashed; }

.demo-stage { padding: 10px 8px 4px; overflow-x: auto; }
.demo-stage svg {
  display: block;
  width: 100%;
  min-width: 620px;
  height: auto;
}

.demo-hint {
  font-size: 0.82rem;
  color: var(--muted);
  padding: 4px 18px 12px;
}
.demo-hint .key { color: var(--accent); font-weight: 600; }

.demo-log {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.75;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  padding: 12px 18px;
  height: 150px;
  overflow-y: auto;
}
.demo-log .log-line { white-space: pre-wrap; color: var(--muted); }
.demo-log .log-line.ok { color: var(--good); }
.demo-log .log-line.err { color: var(--bad); }
.demo-log .log-line.warn { color: var(--warn); }
.demo-log .log-line.sys { color: var(--accent); }

/* ---------- SVG shared classes (used inside demo stages) ---------- */
.demo-stage text {
  font-family: var(--font-mono);
  fill: var(--text);
}
.d-box { fill: var(--surface-2); stroke: var(--border); stroke-width: 1.5; rx: 8; }
.d-box-strong { fill: var(--surface); stroke: var(--muted); stroke-width: 1.5; }
.d-title { font-size: 13px; font-weight: 600; fill: var(--text); }
.d-sub { font-size: 10.5px; fill: var(--muted); }
.d-tiny { font-size: 9.5px; fill: var(--muted); }
.d-wire { stroke: var(--border); stroke-width: 1.5; fill: none; }
.d-wire-active { stroke: var(--accent); stroke-width: 2; fill: none; }
.d-accent { fill: var(--accent); }
.d-good { fill: var(--good); }
.d-bad { fill: var(--bad); }
.d-warn { fill: var(--warn); }
.d-muted { fill: var(--muted); }
.d-dead { opacity: 0.35; }
.d-clickable { cursor: pointer; }
.d-clickable:hover { filter: brightness(1.15); }
.demo-stage [tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Next-project footer nav ---------- */
.project-nav {
  border-top: 1px solid var(--border);
  padding: 36px 0;
}
.project-nav .container {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: space-between;
  align-items: center;
}
.project-nav a { font-size: 0.95rem; font-weight: 550; }
.project-nav .pn-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 4px;
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  section { padding: 56px 0; }
  .hero { padding: 64px 0 56px; }
  .xp-date { margin-left: 0; width: 100%; }
  body { font-size: 15.5px; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition-duration: 0.01ms !important; }
}

/* ---------- Print: hide interactive chrome ---------- */
@media print {
  .site-header, .demo, .theme-toggle, .project-nav { display: none; }
}
