:root {
  --primary: #ff4d3d;
  --primary-600: #e63b2c;
  --primary-hover: #ff5f4a;
  --accent: #ff4d3d;
  --background: #fcfaf7;
  --foreground: #111111;
  --muted: #f3efe9;
  --muted-foreground: #5f5a53;
  --card: #ffffff;
  --card-foreground: #111111;
  --border: #e7dfd5;
  --input: #f5efe8;
  --ring: rgba(255, 77, 61, 0.22);
  --radius: 0.85rem;
  --shadow-sm: 0 8px 24px rgba(17, 17, 17, 0.06);
  --shadow-md: 0 16px 40px rgba(17, 17, 17, 0.10);
  --header-height: 4.5rem;
  --max-width: 1100px;
}

.dark {
  --primary: #ff6b57;
  --primary-hover: #ff7d6a;
  --background: #050505;
  --foreground: #f7f4ee;
  --muted: #111111;
  --muted-foreground: #b0aaa1;
  --card: #141414;
  --card-foreground: #f7f4ee;
  --border: #2b2b2b;
  --input: #171717;
  --ring: rgba(255, 107, 87, 0.30);
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--background);
  color: var(--foreground);
  line-height: 1.65;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.25s ease, color 0.25s ease;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5 {
  font-family: 'Poppins', 'Inter', system-ui, sans-serif;
  color: var(--foreground);
  margin: 0 0 0.5rem 0;
}

a {
  text-decoration: none;
  color: inherit;
}

ul {
  list-style: none;
}

img {
  max-width: 100%;
  height: auto;
}

.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.25rem;
}

.section-header {
  text-align: center;
  margin-bottom: 3rem;
}

.section-header h2 {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 1rem;
  letter-spacing: -0.02em;
}

.divider {
  width: 5rem;
  height: 0.25rem;
  background-color: var(--primary);
  margin: 0 auto 1.5rem;
}

.section-header p {
  color: var(--muted-foreground);
  max-width: 36rem;
  margin: 0 auto;
  line-height: 1.8;
  font-size: 1rem;
}

.highlight {
  color: var(--primary);
}

.emphasis {
  font-weight: 700;
  color: var(--foreground);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  font-weight: 700;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
  letter-spacing: 0.01em;
  box-shadow: var(--shadow-sm);
}

.btn-primary {
  background: linear-gradient(90deg, var(--primary), var(--primary-600));
  color: white;
  border: none;
}

.btn-primary:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--foreground);
}

.btn-outline:hover {
  transform: translateY(-2px);
  background: rgba(17, 17, 17, 0.03);
}

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

.btn i {
  margin-right: 0.5rem;
}

.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: rgba(252, 250, 247, 0.8);
  border-bottom: 1px solid var(--border);
  height: var(--header-height);
  backdrop-filter: blur(8px);
}

.dark .header {
  background-color: rgba(5, 5, 5, 0.88);
  border-bottom-color: var(--border);
}

.header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}

.logo a {
  font-size: 1.25rem;
  font-weight: 700;
  margin-right: 1rem;
}

.desktop-nav {
  display: none;
}

.desktop-nav ul {
  display: flex;
  gap: 1.5rem;
}

.nav-link {
  color: var(--muted-foreground);
  transition: color 0.2s ease;
}

.nav-link:hover {
  color: var(--foreground);
}

.theme-toggle {
  margin-left: auto;
  margin-right: 1rem;
}

#theme-toggle-btn,
#mobile-menu-toggle {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--foreground);
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
}

#theme-toggle-btn:hover,
#mobile-menu-toggle:hover {
  background-color: var(--muted);
}

.light-icon {
  display: block;
}

.dark-icon {
  display: none;
}

.dark .light-icon {
  display: none;
}

.dark .dark-icon {
  display: block;
}

.mobile-menu-btn {
  display: block;
}

.mobile-menu {
  display: none;
  position: absolute;
  top: var(--header-height);
  left: 0;
  right: 0;
  background-color: var(--background);
  border-bottom: 1px solid var(--border);
  padding: 1rem 0;
}

.mobile-menu.active {
  display: block;
}

.mobile-menu ul {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.mobile-menu li {
  padding: 0 1.5rem;
}

.hero {
  position: relative;
  min-height: 100vh;
  padding: 7rem 0 5rem;
  overflow: hidden;
  display: flex;
  align-items: center;
}

.hero-content {
  text-align: center;
  max-width: 54rem;
  margin: 0 auto;
}

.hero h1 {
  font-size: clamp(2.8rem, 6vw, 5rem);
  font-weight: 800;
  line-height: 0.95;
  margin-bottom: 1.25rem;
  letter-spacing: -0.03em;
  font-family: 'Playfair Display', 'Poppins', serif;
}

.hero p {
  font-size: 1.1rem;
  color: var(--muted-foreground);
  margin-bottom: 2rem;
  max-width: 42rem;
  margin-left: auto;
  margin-right: auto;
}

.hero-buttons {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  justify-content: center;
  align-items: center;
}

.scroll-down {
  position: absolute;
  bottom: 2rem;
  left: 0;
  right: 0;
  text-align: center;
  display: flex;
  justify-content: center;
  pointer-events: none;
}

.scroll-down a {
  pointer-events: auto;
}

.scroll-down a {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--muted-foreground);
  transition: color 0.2s ease;
}

.scroll-down a:hover {
  color: var(--foreground);
}

.scroll-down span {
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
}

.bounce {
  animation: bounce 2s infinite;
}

@keyframes bounce {
  0%, 20%, 50%, 80%, 100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-10px);
  }
  60% {
    transform: translateY(-5px);
  }
}

.about,
.projects {
  padding: 5rem 0;
  background: var(--muted);
}

.about-content {
  max-width: 48rem;
  margin: 0 auto;
}

.about-text h3 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.about-text p {
  color: var(--muted-foreground);
  margin-bottom: 1.5rem;
}

.info-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.info-card,
.contact-card,
.contact-form,
.project-card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.info-card:hover,
.contact-card:hover,
.project-card:hover {
  transform: translateY(-3px);
  border-color: var(--primary);
}

.info-card {
  padding: 1rem;
}

.info-card h4 {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.info-card p {
  color: var(--muted-foreground);
  margin-bottom: 0;
}

.skills {
  padding: 5rem 0;
}

.skills-icons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
  gap: 0.85rem;
  max-width: 50rem;
  margin: 1.5rem auto 0;
}

.skills-icons a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.85rem;
  border-radius: 0.9rem;
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.skills-icons a:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}

.skills-icons img {
  width: 42px;
  height: 42px;
  display: block;
}

.project-filter {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 2rem;
}

.filter-btn {
  background: none;
  border: none;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  cursor: pointer;
  color: var(--muted-foreground);
  border-radius: var(--radius);
  transition: all 0.2s ease;
}

.filter-btn:hover {
  background-color: rgba(255, 77, 61, 0.1);
  color: var(--primary);
}

.filter-btn.active {
  background-color: var(--primary);
  color: white;
}

.projects-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

.project-card {
  overflow: hidden;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.project-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-md);
}

.project-image {
  position: relative;
  height: 12rem;
  overflow: hidden;
}

.project-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.project-card:hover .project-image img {
  transform: scale(1.05);
}

.project-content {
  padding: 1.5rem;
}

.project-content h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.project-content p {
  color: var(--muted-foreground);
  margin-bottom: 1rem;
}

.project-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.project-tags span {
  background-color: rgba(255, 77, 61, 0.1);
  color: var(--primary);
  padding: 0.25rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.75rem;
}

.project-card code {
  background: rgba(255, 77, 61, 0.08);
  color: var(--foreground);
  padding: 0.12rem 0.35rem;
  border-radius: 0.35rem;
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: 0.9em;
}

.project-links {
  display: flex;
  gap: 0.5rem;
}

.contact {
  padding: 5rem 0;
}

.contact-container {
  display: grid;
  justify-items: center;
  align-items: center;
  gap: 2rem;
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  text-align: center;
}

.contact-info {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  width: min(100%, 720px);
}

.contact-card {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1.5rem;
}

.contact-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  border-radius: 9999px;
  background-color: rgba(255, 77, 61, 0.1);
  color: var(--primary);
  font-size: 1.25rem;
}

.contact-details h3 {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.contact-details a {
  color: var(--muted-foreground);
  transition: color 0.2s ease;
}

.contact-details a:hover {
  color: var(--primary);
}

.contact-form {
  padding: 1.5rem;
  width: min(100%, 720px);
  margin: 0 auto;
}

.contact-container > .contact-form:only-child {
  grid-column: 1 / -1;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--input);
  border-radius: var(--radius);
  background-color: var(--background);
  color: var(--foreground);
  font-family: inherit;
  font-size: 1rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 2px rgba(255, 77, 61, 0.15);
}

.btn:focus-visible,
.filter-btn:focus-visible,
.form-group input:focus-visible,
.form-group textarea:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.footer {
  padding: 2rem 0;
  border-top: 1px solid var(--border);
  text-align: center;
}

.social-links {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.social-links a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 9999px;
  background-color: var(--muted);
  color: var(--foreground);
  font-size: 1.2rem;
  transition: all 0.2s ease;
}

.social-links a:hover {
  background-color: var(--primary);
  color: white;
  transform: translateY(-3px);
}

.copyright {
  color: var(--muted-foreground);
  font-size: 0.875rem;
}

.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background-color: var(--card);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  display: flex;
  align-items: flex-start;
  max-width: 24rem;
  z-index: 1000;
  transform: translateY(150%);
  transition: transform 0.3s ease;
}

.toast.show {
  transform: translateY(0);
}

.toast-content {
  flex: 1;
}

.toast-title {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.toast-message {
  color: var(--muted-foreground);
  font-size: 0.875rem;
}

.toast-close {
  background: none;
  border: none;
  color: var(--muted-foreground);
  font-size: 1.25rem;
  cursor: pointer;
  margin-left: 0.5rem;
}

.progress-bar {
  position: fixed;
  inset: auto 0 0 0;
  height: 3px;
  background: rgba(17, 17, 17, 0.08);
  z-index: 1200;
}

.progress-bar span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width 0.12s linear;
}

.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.7s cubic-bezier(0.22, 1, 0.36, 1), transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}

.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.is-hidden {
  opacity: 0;
  transform: translateY(18px);
}

.is-visible {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.hero .highlight {
  color: var(--primary);
}

.hero .emphasis {
  color: var(--foreground);
  font-weight: 700;
}

.scroll-down a {
  color: var(--muted-foreground);
}

.scroll-down a:hover {
  color: var(--foreground);
}

a[download] {
  display: none;
}

@media (min-width: 640px) {
  .hero h1 {
    font-size: 3rem;
  }

  .hero-buttons {
    flex-direction: row;
  }

  .info-cards {
    grid-template-columns: repeat(2, 1fr);
  }

  .form-row {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 768px) {
  .desktop-nav {
    display: block;
  }

  .mobile-menu-btn {
    display: none;
  }

  .scroll-down {
    display: block;
  }

  .projects-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Keep contact stacked on tablet to avoid layout shifts when contact-info is missing */
  .contact-container {
    display: grid;
    grid-template-columns: 1fr;
    align-items: center;
    gap: 1.5rem;
  }
}

@media (min-width: 1024px) {
  .hero h1 {
    font-size: 3.5rem;
  }

  .projects-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  /* Desktop: show contact info + form side-by-side */
  .contact-container {
    grid-template-columns: 1fr 2fr;
    align-items: flex-start;
  }
}

/* ---- 3D Skills Scene ---- */
.skills-3d {
  position: relative;
  padding: 3rem 0 6rem;
  perspective: 1200px;
  overflow: visible;
}
.skills-3d .scene {
  position: relative;
  width: 100%;
  height: 70vh;
  transform-style: preserve-3d;
  will-change: transform;
}
.skills-3d .panel {
  --z: 0px;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) translateZ(var(--z)) scale(0.75);
  transform-style: preserve-3d;
  width: min(760px, 88%);
  max-width: 760px;
  padding: 1.5rem;
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02));
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 1rem;
  box-shadow: 0 20px 40px rgba(2,2,2,0.28);
  color: var(--card-foreground);
  opacity: 0;
  filter: none;
  pointer-events: none;
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 1rem;
  align-items: center;
  justify-items: start;
  transition: transform 0.2s ease-out, opacity 0.2s ease-out;
  will-change: transform, opacity;
}
.skills-3d .panel .panel-icon img {
  width: 48px;
  height: 48px;
}
.skills-3d .panel .panel-title {
  margin: 0 0 0.25rem;
  font-size: 1.25rem;
}
.skills-3d .panel .panel-desc {
  margin: 0;
  color: rgba(255,255,255,0.85);
}

@media (max-width: 900px) {
  .skills-3d .scene { height: 56vh; }
  .skills-3d .panel { width: min(640px, 92%); grid-template-columns: 56px 1fr; }
}

@media (hover: none) and (pointer: coarse), (max-width: 767px) {
  .skills-3d { perspective: none; }
  .skills-3d .scene { position: static; height: auto; }
  .skills-3d .panel { position: relative; transform: none; opacity: 1; filter: none; pointer-events: auto; margin: 0 0 1rem; }
}

@media (max-width: 900px) {
  #skills-3d {
    display: none !important;
  }
}

/* ---- Cap Widget ---- */
.cap-container {
  display: flex;
  justify-content: center;
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}

cap-widget {
  --cap-background: var(--card);
  --cap-border-color: var(--border);
  --cap-border-radius: var(--radius);
  --cap-color: var(--foreground);
  --cap-checkbox-border: 1px solid var(--input);
  --cap-checkbox-border-radius: 6px;
  --cap-checkbox-background: var(--background);
  --cap-font: 'Inter', system-ui, -apple-system, sans-serif;
  --cap-spinner-color: var(--primary);
  --cap-spinner-background-color: var(--muted);
}

.dark cap-widget {
  --cap-background: var(--card);
  --cap-border-color: var(--border);
  --cap-color: var(--foreground);
  --cap-checkbox-border: 1px solid var(--border);
  --cap-checkbox-background: var(--input);
  --cap-spinner-color: var(--primary);
  --cap-spinner-background-color: #222;
}
