/* ---------- THEME ---------- */
:root {
  --bg: #f8fafc;
  --text: #0f172a;
  --muted: #334155;
  --primary: #0b65ff;
  --secondary: #7c4dff;
  --accent: #ff7a7a;
  --card: #ffffff;
  --footer: #0b1220;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(13, 38, 76, .08);
  --blur: 12px;

  /* Typography scale */
  --fs-body: clamp(1rem, .2vw + .95rem, 1.075rem);
  --fs-h1: clamp(2.2rem, 3.5vw + 1rem, 3.4rem);
  --fs-h2: clamp(1.6rem, 2.2vw + .75rem, 2.4rem);
  --fs-h3: clamp(1.2rem, .8vw + .9rem, 1.5rem);
  --lh: 1.8;
}

body.dark {
  --bg: #0b0f17;
  --text: #e6ecff;
  --muted: #9fb0d3;
  --primary: #4dabf7;
  --secondary: #a58bff;
  --accent: #ff9a9a;
  --card: #121827;
  --footer: #070b12;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
}

/* ---------- BASE ---------- */
* {
  box-sizing: border-box
}

html,
body {
  margin: 0;
  padding: 0;
  scroll-behavior: smooth;
}

body {
  font-family: "Inter", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: var(--lh);
  font-size: var(--fs-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

img {
  max-width: 100%;
  display: block
}

a {
  color: inherit;
  transition: opacity 0.2s ease;
}

a:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 4px;
}

/* ---------- NAVBAR ---------- */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 72px;
  padding: 0 5%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  backdrop-filter: saturate(180%) blur(var(--blur));
  background: color-mix(in oklab, var(--card) 85%, transparent);
  box-shadow: var(--shadow);
  z-index: 1000;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: .1px;
  text-decoration: none;
}

.logo img {
  height: 40px;
  width: 40px;
  border-radius: 50%
}

.nav-links {
  display: flex;
  gap: 28px;
  align-items: center
}

.nav-links a {
  position: relative;
  text-decoration: none;
  font-weight: 600;
  opacity: .9;
  padding: 8px 0;
}

.nav-links a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -6px;
  height: 3px;
  width: 0;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  transition: width .25s ease;
}

.nav-links a:hover::after,
.nav-links a.active::after {
  width: 100%
}

.cta-small {
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid color-mix(in oklab, var(--primary) 40%, transparent);
  text-decoration: none;
  font-weight: 700;
}

.cta-small:hover {
  background: var(--primary);
  color: #fff;
}

/* Mobile menu */
.hamburger {
  display: none;
  border: none;
  background: transparent;
  font-size: 1.5rem;
  line-height: 0;
  cursor: pointer;
  color: var(--text);
}

.drawer {
  position: fixed;
  top: 72px;
  left: 0;
  right: 0;
  transform: translateY(-120%);
  transition: transform .35s ease;
  background: color-mix(in oklab, var(--card) 96%, transparent);
  backdrop-filter: blur(var(--blur));
  box-shadow: var(--shadow);
  z-index: 999;
  padding: 14px 5%;
}

.drawer.open {
  transform: translateY(0)
}

.drawer a {
  display: block;
  padding: 14px 0;
  text-decoration: none;
  font-weight: 700;
  border-bottom: 1px solid color-mix(in oklab, var(--muted) 12%, transparent);
}

/* ---------- HEADER ---------- */
header {
  margin-top: 72px;
  padding: 120px 20px 90px;
  text-align: center;
  background:
    radial-gradient(1200px 500px at 50% -100px, color-mix(in oklab, var(--primary) 18%, transparent), transparent 60%),
    linear-gradient(135deg, color-mix(in oklab, var(--primary) 12%, transparent), color-mix(in oklab, var(--secondary) 12%, transparent));
  clip-path: polygon(0 0, 100% 0, 100% 94%, 0 100%);
}

header .avatar {
  height: 150px;
  width: 150px;
  margin: 0 auto 22px;
  border-radius: 50%;
  border: 4px solid color-mix(in oklab, #fff 60%, transparent);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .15);
  animation: float 6s ease-in-out infinite;
}

header h1 {
  font-size: var(--fs-h1);
  margin: 0 0 8px;
  letter-spacing: -.5px
}

header p {
  max-width: 760px;
  margin: 0 auto;
  color: var(--muted);
  font-weight: 500
}

.header-btns {
  display: flex;
  gap: 14px;
  justify-content: center;
  margin-top: 28px;
  flex-wrap: wrap
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 22px;
  border-radius: 999px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  min-height: 48px;
  min-width: 48px;
  transition: transform .2s ease, box-shadow .2s ease, opacity .2s ease;
  box-shadow: 0 10px 20px rgba(0, 0, 0, .08);
}

.btn:active {
  transform: translateY(1px)
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  border: none;
}

.btn-secondary {
  background: transparent;
  color: var(--primary);
  border: 2px solid color-mix(in oklab, var(--primary) 50%, transparent);
}

.btn:hover {
  box-shadow: 0 14px 26px rgba(0, 0, 0, .12);
  transform: translateY(-2px);
}

/* ---------- SECTIONS ---------- */
.section {
  padding: 90px 20px
}

.section-title {
  text-align: center;
  margin-bottom: 40px
}

.section-title h2 {
  font-size: var(--fs-h2);
  margin: 0
}

.muted {
  color: var(--muted)
}

/* ---------- ENHANCED PROJECTS SECTION ---------- */
.projects-section {
  background: linear-gradient(180deg, transparent, color-mix(in oklab, var(--secondary) 4%, transparent));
  position: relative;
}

/* Category Tabs */
.category-tabs {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 40px;
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}

.category-tab {
  padding: 12px 24px;
  border-radius: 50px;
  background: var(--card);
  border: 2px solid color-mix(in oklab, var(--muted) 15%, transparent);
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.category-tab:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}

.category-tab.active {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  border-color: transparent;
}

.category-tab:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Projects Grid */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 28px;
  max-width: 1400px;
  margin: 0 auto;
}

.project-card {
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform .3s ease, box-shadow .3s ease, filter .3s ease;
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.project-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

.project-image {
  position: relative;
  overflow: hidden;
  height: 200px;
}

.project-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .5s ease;
}

.project-card:hover img {
  transform: scale(1.06);
}

.project-card-content {
  padding: 24px;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}

.project-card h3 {
  margin: .2rem 0 .35rem 0;
  font-size: 1.25rem;
  line-height: 1.3;
}

.project-card p {
  margin: 0 0 16px 0;
  font-size: .95rem;
  color: var(--muted);
  flex-grow: 1;
}

.project-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
}

.tech-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tech-tag {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 700;
  background: color-mix(in oklab, var(--primary) 12%, transparent);
  color: var(--primary);
}

.project-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  text-decoration: none;
  transition: transform 0.2s ease;
}

.project-link:hover {
  transform: scale(1.1);
}

.project-link:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.category-badge {
  position: absolute;
  top: 16px;
  left: 16px;
  padding: 6px 12px;
  border-radius: 50px;
  font-size: 0.75rem;
  font-weight: 800;
  background: var(--card);
  color: var(--primary);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  z-index: 2;
}

/* Empty state */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}

.empty-state i {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.5;
}

/* Animation for category switching */
.projects-container {
  position: relative;
  min-height: 600px;
}

.category-content {
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.category-content.hidden {
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
}

.category-content.active {
  opacity: 1;
  transform: translateY(0);
}

/* ---------- SKILLS ---------- */
.skills-container {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 24px;
}

.skill-category {
  background: color-mix(in oklab, var(--card) 98%, transparent);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: var(--shadow);
  transition: transform .25s ease, box-shadow .25s ease;
}

.skill-category:hover {
  transform: translateY(-6px);
  box-shadow: 0 18px 40px rgba(0, 0, 0, .12)
}

.skill-category h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--primary);
  font-size: var(--fs-h3);
  margin: 0 0 14px
}

.skill-list {
  display: grid;
  gap: 16px
}

.skill-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center
}

.skill-info {
  display: flex;
  align-items: center;
  gap: 12px
}

.skill-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, color-mix(in oklab, var(--primary) 20%, transparent), color-mix(in oklab, var(--secondary) 16%, transparent));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  font-size: 1.2rem;
}

.skill-name {
  font-weight: 700
}

.bar {
  grid-column: 1 / -1;
  height: 10px;
  border-radius: 999px;
  background: color-mix(in oklab, var(--muted) 14%, transparent);
  overflow: hidden;
}

.bar>span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  border-radius: inherit;
  transition: width 1.2s ease;
}

/* ---------- ABOUT ---------- */
.about-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 40px;
}

.about-img {
  flex: 1;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  position: relative
}

.about-img::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  opacity: .1
}

.about-content {
  flex: 1
}

.about-content h2 {
  font-size: var(--fs-h2);
  margin: 0 0 12px
}

.about-content p {
  margin: 0 0 16px
}

.highlight {
  font-weight: 800;
  color: var(--primary)
}

.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-top: 18px
}

.stat-item {
  background: var(--card);
  padding: 20px;
  border-radius: var(--radius);
  text-align: center;
  box-shadow: var(--shadow)
}

.stat-item .number {
  font-size: clamp(1.8rem, 2.4vw + 1rem, 2.8rem);
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
  margin-bottom: 8px
}

@media (max-width: 992px) {
  .about-container {
    flex-direction: column
  }
}

/* ---------- CONTACT ---------- */
.contact-wrap {
  max-width: 920px;
  margin: 0 auto;
  padding: 0 20px
}

.contact-intro {
  max-width: 680px;
  margin: 0 auto 20px;
  text-align: center;
  color: var(--muted)
}

.contact-form {
  max-width: 640px;
  margin: 24px auto 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
  text-align: left;
}

.form-group {
  position: relative
}

.contact-form input,
.contact-form textarea,
.contact-form select {
  width: 100%;
  padding: 18px 14px 14px;
  border: 1px solid color-mix(in oklab, var(--muted) 20%, transparent);
  background: var(--card);
  border-radius: 12px;
  color: var(--text);
  font: inherit;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.contact-form textarea {
  min-height: 150px;
  resize: vertical
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px color-mix(in oklab, var(--primary) 15%, transparent);
}

.form-group input:invalid:not(:placeholder-shown) {
  border-color: var(--accent);
}

.form-group input:invalid:not(:placeholder-shown) + .fl-label {
  color: var(--accent);
}

/* Floating labels */
.fl-label {
  position: absolute;
  left: 12px;
  top: 12px;
  padding: 2px 6px;
  background: var(--card);
  color: var(--muted);
  font-size: .85rem;
  pointer-events: none;
  transition: transform .18s ease, opacity .18s ease;
  transform-origin: left top;
  opacity: .9;
}

.contact-form input::placeholder,
.contact-form textarea::placeholder {
  color: transparent
}

.contact-form input:placeholder-shown+.fl-label,
.contact-form textarea:placeholder-shown+.fl-label {
  transform: translateY(10px) scale(1.05);
  opacity: .7;
}

.contact-form button {
  align-self: center;
  width: 100%;
  max-width: 340px;
  padding: 14px 20px;
  border: none;
  border-radius: 999px;
  font-weight: 900;
  font-size: 1rem;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  transition: filter .2s ease, transform .2s ease;
}

.contact-form button:hover {
  filter: saturate(115%)
}

.spinner {
  display: none;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255, 255, 255, .35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 1s linear infinite
}

#formStatus {
  min-height: 24px;
  text-align: center
}

#formStatus[role="status"] {
  color: var(--primary);
  font-weight: 700
}

/* ---------- FOOTER ---------- */
footer {
  padding: 80px 20px 30px;
  background: var(--footer);
  color: #e6ecff;
  position: relative;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.footer-container {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 34px;
}

.footer-col h3 {
  margin: 0 0 14px;
  font-size: 1.2rem
}

.footer-col p {
  margin: 0 0 12px;
  opacity: .85
}

.footer-social {
  display: flex;
  gap: 12px;
  margin-top: 10px
}

.footer-social a {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in oklab, #fff 10%, transparent);
  color: #fff;
  text-decoration: none;
  transition: transform .2s ease, background .2s ease;
}

.footer-social a:hover {
  transform: translateY(-4px);
  background: linear-gradient(135deg, var(--primary), var(--secondary))
}

.footer-links {
  display: flex;
  flex-direction: column;
  gap: 10px
}

.footer-links a {
  color: #fff;
  text-decoration: none;
  opacity: .85;
  display: flex;
  align-items: center;
  gap: 10px
}

.footer-links a:hover {
  opacity: 1;
  color: color-mix(in oklab, #fff 95%, var(--primary))
}

.copyright {
  text-align: center;
  padding-top: 24px;
  margin-top: 24px;
  border-top: 1px solid rgba(255, 255, 255, .12);
  opacity: .7;
  font-size: .9rem
}

/* ---------- FLOATERS ---------- */
.theme-toggle {
  position: fixed;
  top: 82px;
  right: 18px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  z-index: 1001;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  font-size: 1.2rem;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .2s ease;
}

.theme-toggle:hover {
  transform: scale(1.1);
  background: color-mix(in oklab, var(--card) 80%, var(--primary));
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 4px;
}

.whatsapp-btn {
  position: fixed;
  right: 22px;
  bottom: 28px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #25D366;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-size: 1.6rem;
  box-shadow: 0 10px 24px rgba(0, 0, 0, .25);
  z-index: 1000;
  transition: transform .2s ease;
}

.whatsapp-btn:hover {
  transform: scale(1.06)
}

#backToTop {
  position: fixed;
  right: 22px;
  bottom: 100px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  box-shadow: var(--shadow);
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity .2s ease, transform .2s ease;
}

#backToTop.show {
  opacity: 1;
  visibility: visible
}

#backToTop:hover {
  transform: translateY(-6px)
}

/* ---------- ANIMATIONS ---------- */
@keyframes spin {
  to {
    transform: rotate(360deg)
  }
}

@keyframes float {
  0% {
    transform: translateY(0)
  }

  50% {
    transform: translateY(-8px)
  }

  100% {
    transform: translateY(0)
  }
}

/* Fade in animation for project cards */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Animations */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.reveal.active {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .reveal {
    transition: none;
    opacity: 1;
    transform: none;
  }
}

/* ---------- RESPONSIVE TWEAKS ---------- */
@media (max-width: 1024px) {
  header {
    padding: 110px 20px 80px
  }
}

@media (max-width: 920px) {
  .nav-links {
    display: none
  }

  .hamburger {
    display: block
  }

  .projects-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  }
}

@media (max-width: 768px) {
  .category-tabs {
    flex-direction: column;
    align-items: center;
  }

  .category-tab {
    width: 100%;
    max-width: 300px;
    text-align: center;
  }

  .projects-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  header .avatar {
    height: 128px;
    width: 128px
  }

  .project-card-content {
    padding: 16px;
  }
}
