/* ===============================
   Reset & Base
   =============================== */
*, *::before, *::after { box-sizing: border-box; }
html, body, h1, h2, h3, h4, h5, h6, p, figure, blockquote, dl, dd { margin: 0; }
ul[role='list'], ol[role='list'], ul, ol { list-style: none; padding: 0; margin: 0; }
html:focus-within { scroll-behavior: smooth; }
body { min-height: 100vh; text-rendering: optimizeLegibility; -webkit-font-smoothing: antialiased; }
img, picture { max-width: 100%; display: block; }
input, button, textarea, select { font: inherit; }
:root {
  /* Layout */
  --maxw: 1120px;
  --bottom-nav-h: 56px;

  /* Colors (dark default) */
  --bg: #0f1216;
  --surface: #151a20;
  --elev: #1b2129;
  --text: #e6e8eb;
  --text-muted: #a9b0bb;
  --primary: #8aa1ff; /* subtle bluish */
  --accent: #8bd0ff;
  --border: #2a3038;

  /* Typography */
  --font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  --fs-base: 16px;
  --lh-base: 1.6;
  --h1: clamp(2rem, 4vw, 3rem);
  --h2: clamp(1.5rem, 3vw, 2.25rem);
  --h3: clamp(1.125rem, 2vw, 1.5rem);

  /* Spacing scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  /* Radius & Shadows */
  --radius: 14px;
  --shadow-1: 0 1px 2px rgba(0,0,0,.2), 0 4px 12px rgba(0,0,0,.2);
  --shadow-focus: 0 0 0 3px rgba(138,161,255,.45);

  /* Motion */
  --dur-1: 200ms;
  --ease-1: cubic-bezier(.2,.7,.2,1);
}

html[data-theme="light"] {
  --bg: #ffffff;
  --surface: #f7f8fa;
  --elev: #ffffff;
  --text: #0e1116;
  --text-muted: #4b5563;
  --primary: #3b82f6;
  --accent: #0ea5e9;
  --border: #e5e7eb;
}

/* prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-family);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
}

/* Utilities */
.container { max-width: var(--maxw); margin-inline: auto; padding-inline: var(--space-4); }
.section { padding-block: var(--space-8); }
.flow > * + * { margin-top: var(--space-4); }
.muted { color: var(--text-muted); }
.tap-target { min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }

h1 { font-size: var(--h1); line-height: 1.1; letter-spacing: -0.01em; }
h2 { font-size: var(--h2); line-height: 1.2; letter-spacing: -0.01em; }
h3 { font-size: var(--h3); line-height: 1.3; }

/* Focus states */
a, button, [tabindex] { outline: none; }
a:focus-visible, button:focus-visible, .focus-ring { box-shadow: var(--shadow-focus); border-radius: calc(var(--radius) - 4px); }

/* Buttons */
.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 10px 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  transition: transform var(--dur-1) var(--ease-1), background var(--dur-1), border-color var(--dur-1), color var(--dur-1);
  text-decoration: none;
}
.btn:hover { transform: translateY(-1px) scale(1.01); background: var(--elev); text-decoration: none; }
.btn:active { transform: translateY(0) scale(0.99); text-decoration: none; }
.btn-primary { background: var(--primary); color: #0b1020; border-color: transparent; }
.btn-primary:hover { background: color-mix(in oklab, var(--primary) 72%, black 28%); color: #ffffff; }
.btn-ghost { background: transparent; }

.icon-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 8px 12px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  transition: transform var(--dur-1) var(--ease-1), background var(--dur-1);
  text-decoration: none;
}
.icon-btn:hover { transform: translateY(-1px) scale(1.02); background: var(--elev); }

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in oklab, var(--bg) 85%, transparent);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
}
.topbar__inner { display: flex; align-items: center; gap: var(--space-4); padding-block: var(--space-3); }
.brand {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--primary); color: #0b1020; font-weight: 700; justify-content: center;
  text-decoration: none;
}
.primary-nav { display: none; }
.nav-list { display: flex; gap: var(--space-4); }
.nav-link {
  text-decoration: none; color: var(--text);
  padding: 8px 12px; border-radius: var(--radius);
  transition: background var(--dur-1), color var(--dur-1), border-color var(--dur-1);
  border-bottom: 2px solid transparent;
}
/* Hover: highlight with color/bottom border, no underline */
.nav-link:hover { color: var(--primary); border-bottom-color: color-mix(in oklab, var(--primary) 70%, transparent); text-decoration: none; }
/* Active: primary color + solid bottom border */
.nav-link[aria-current="true"] { color: var(--primary); border-bottom-color: var(--primary); background: transparent; }
.topbar__actions { margin-left: auto; display: flex; gap: var(--space-2); }

/* Hero */
.hero { padding-block-start: var(--space-7); }
.hero__inner { display: grid; gap: var(--space-6); align-items: center; }
.hero__title { font-weight: 800; }
.hero__subtitle { color: var(--text-muted); margin-top: var(--space-2); font-size: 1.125rem; }
.hero__lede { margin-top: var(--space-4); max-width: 60ch; }
.hero__cta { margin-top: var(--space-5); display: flex; gap: var(--space-3); flex-wrap: wrap; }
.stack-chips { margin-top: var(--space-5); display: flex; gap: var(--space-2); flex-wrap: wrap; }
.stack-chips li { background: var(--elev); border: 1px solid var(--border); padding: 6px 10px; border-radius: 999px; color: var(--text); }

.hero__media { justify-self: center; }
.hero__media img { border-radius: 50%; box-shadow: var(--shadow-1); outline: 4px solid color-mix(in oklab, var(--primary), transparent 70%); }

/* Cards grid */
.cards-grid { display: grid; gap: var(--space-5); }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  overflow: clip;
  transition: transform var(--dur-1) var(--ease-1);
}
.card:hover { transform: translateY(-2px) scale(1.01); }
.card__media { aspect-ratio: 16 / 9; background: #0b1020; }
.card__media img { width: 100%; height: 100%; object-fit: cover; }
.card__body { padding: var(--space-4); display: grid; gap: var(--space-3); }
.card__title { font-size: 1.125rem; font-weight: 700; }
.card__desc { color: var(--text-muted); }
.card__actions { display: flex; gap: var(--space-3); flex-wrap: wrap; }

/* Tech grid */
.tech-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
  gap: var(--space-4);
}
.tech-grid img {
  width: 72px; height: 72px; object-fit: contain; margin-inline: auto;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,.2));
}

/* Skills groups */
.skills-groups { display: grid; gap: var(--space-6); }
#skills h2 { margin-bottom: var(--space-5); } /* spacing fix */
.skills-groups section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
}
.tag-list { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-3); }
.tag-list li { padding: 6px 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--elev); }

/* Contact */
.social-list { display: flex; gap: var(--space-3); flex-wrap: wrap; }
.social-list a { text-decoration: none; color: var(--text); border: 1px solid var(--border); padding: 8px 12px; border-radius: var(--radius); background: var(--surface); }
.social-list a:hover { background: var(--elev); }

/* Footer */
.footer { border-top: 1px solid var(--border); padding-block: var(--space-5); background: var(--surface); }
.footer__inner { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.back-to-top { text-decoration: none; }

/* Bottom Nav (mobile) */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 60;
  height: var(--bottom-nav-h);
  padding-inline: var(--space-3);
  padding-bottom: env(safe-area-inset-bottom);
  display: flex; align-items: center; justify-content: center;
}
.bottom-nav__links {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: var(--space-2);
  flex: 1 1 auto;
  min-width: 0;
}
.bottom-nav__utils {
  display: flex; gap: var(--space-2);
  flex: 0 0 auto;
}
.bottom-link {
  padding: 8px 10px;
  text-align: center;
  text-decoration: none;
  color: var(--text);
  display: flex; align-items: center; justify-content: center;
  min-width: 44px; min-height: 44px;
  border-radius: var(--radius);
}
.bottom-link[aria-current="true"] { color: var(--primary); box-shadow: inset 0 -2px 0 var(--primary); }

/* Icon buttons inside bottom nav */
.bottom-nav .icon-btn {
  min-width: 44px; min-height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 12px;
}

/* Skip link */
.skip-link {
  position: absolute; left: -9999px; top: auto; width: 1px; height: 1px; overflow: hidden;
}
.skip-link:focus {
  position: fixed; left: var(--space-4); top: var(--space-4); width: auto; height: auto;
  padding: 8px 12px; background: var(--primary); color: #0b1020; border-radius: var(--radius); z-index: 100;
}

/* Media queries */
@media (min-width: 641px) {
  .primary-nav { display: block; }
  .bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 60;
  height: var(--bottom-nav-h);
  padding-inline: var(--space-3);
  padding-bottom: env(safe-area-inset-bottom);
  display: flex; align-items: center; justify-content: center;
}
  .hero__inner { grid-template-columns: 2fr 1fr; }
  .cards-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1025px) {
  .cards-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Anchor offset */
section { scroll-margin-top: 80px; }

/* Ensure footer isn't obscured on mobile */
@media (max-width: 640px) {
  body { padding-bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom)); }
}

.only-mobile { display: inline-flex; }
@media (min-width: 641px) {
  .only-mobile { display: none !important; }
}

.topbar .icon-btn { min-width: 44px; min-height: 44px; }

@media (min-width: 641px) {
    .bottom-nav { display: none !important; }
}

/* Contact Form */
.form { display: grid; gap: var(--space-4); max-width: 640px; }
.form-row { display: grid; gap: var(--space-2); }
.form-row label { font-weight: 600; }
.form-row input[type="text"],
.form-row input[type="email"],
.form-row textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-1);
}
.form-row textarea { resize: vertical; min-height: 140px; }
.form-row input:focus,
.form-row textarea:focus { box-shadow: var(--shadow-focus); border-color: color-mix(in oklab, var(--primary) 70%, transparent); }
.form-actions { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.form-status { min-height: 1.5em; }
.form-status.is-success { color: #22c55e; } /* green-ish */
.form-status.is-error { color: #ef4444; } /* red-ish */
#send-btn[disabled] { opacity: .7; cursor: not-allowed; }
