/* ===== VARIABLES ===== */
:root {
  --bg-primary: #121212;
  --bg-secondary: #1e1e1e;
  --text-primary: #e0e0e0;
  --text-secondary: #a0a0a0;
  --accent: #ffd700;
  --card-bg: #2a2a2a;
  --border: #3a3a3a;
  --shadow: rgba(0,0,0,0.3);

  --light-bg-primary: #ffffff;
  --light-bg-secondary: #f5f5f5;
  --light-text-primary: #333333;
  --light-text-secondary: #555555;
  --light-accent: #f9ca24;
  --light-card-bg: #ffffff;
  --light-border: #e0e0e0;
  --light-shadow: rgba(0,0,0,0.1);
}

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

html { scroll-behavior: smooth; font-size: 16px; background-color: #121212; }
html.light-theme-root { background-color: #ffffff; }

body {
  font-family: "Inter", sans-serif;
  line-height: 1.6;
  background-color: transparent;
  color: var(--text-primary);
  transition: color 0.3s ease;
  min-width: 360px;
  overflow-x: hidden;
}

.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 16px; }

/* Matrix */
#matrixCanvas {
  position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: -1; opacity: 0.15; pointer-events: none;
}

body { background-color: transparent; }
.light-theme { background-color: transparent; }
.navbar, .portfolio, .skills, .contact, .footer { backdrop-filter: blur(5px); }

/* Theme toggle */
.theme-toggle {
  position: fixed; bottom: 16px; right: 16px; z-index: 1000;
  width: 48px; height: 48px; border-radius: 50%; border: none;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem; transition: all 0.3s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  background-color: var(--accent); color: var(--bg-primary);
}
.theme-toggle:hover { transform: scale(1.1); }
.light-theme .fa-sun { display: none; }
.light-theme .fa-moon { display: block; }
.dark-theme .fa-sun { display: block; }
.dark-theme .fa-moon { display: none; }

/* Scroll to top */
.scroll-to-top {
  position: fixed; bottom: 80px; right: 16px; z-index: 1000;
  width: 48px; height: 48px; border-radius: 50%; border: none;
  background-color: var(--accent); color: var(--bg-primary);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem; transition: all 0.3s ease;
  opacity: 0; visibility: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.scroll-to-top.visible { opacity: 1; visibility: visible; }
.scroll-to-top:hover { transform: translateY(-2px); }

/* Accessibility */
.btn:focus, .nav-link:focus, .theme-toggle:focus, .scroll-to-top:focus {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.btn:disabled { opacity: 0.7; cursor: not-allowed; }

.loading-spinner {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid transparent; border-top: 2px solid currentColor;
  border-radius: 50%; animation: spin 1s linear infinite; margin-right: 8px;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

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

/* Navbar */
.navbar {
  position: sticky; top: 0; z-index: 100; padding: 1rem 0;
  background-color: var(--bg-primary);
  box-shadow: 0 2px 8px var(--shadow);
  transition: background-color 0.3s ease;
}
.navbar-content { display: flex; justify-content: space-between; align-items: center; }
.logo { font-size: 1.25rem; font-weight: 700; text-decoration: none; color: var(--text-primary); }
.nav-menu { display: flex; gap: 1.5rem; }
.nav-link { text-decoration: none; font-weight: 500; color: var(--text-primary); transition: color 0.3s; font-size: 0.9rem; }
.nav-link:hover { color: var(--accent); }
.menu-toggle { display: none; background: none; border: none; font-size: 1.25rem; cursor: pointer; color: var(--text-primary); }
.mobile-menu { display: none; flex-direction: column; padding: 1rem; background-color: var(--bg-secondary); }
.mobile-menu .nav-link { padding: 0.75rem 0; text-align: center; border-bottom: 1px solid var(--border); font-size: 1rem; }
.mobile-menu .nav-link:last-child { border-bottom: none; }

/* Hero */
.hero { padding: 3rem 0; min-height: 80vh; display: flex; align-items: center; }
.hero-content { display: flex; align-items: center; gap: 2rem; width: 100%; }
.hero-text { flex: 1; min-width: 0; }
.subtitle { margin-bottom: 0.5rem; color: var(--text-secondary); font-size: 1rem; }
.title { font-size: 2rem; font-weight: 700; margin-bottom: 0.5rem; color: var(--text-primary); line-height: 1.2; }
.name { font-size: 1.75rem; font-weight: 700; margin-bottom: 1rem; color: var(--accent); line-height: 1.2; }
.description { margin-bottom: 1.5rem; color: var(--text-secondary); font-size: 0.95rem; line-height: 1.5; }
.hero-links { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.btn { display: inline-flex; align-items: center; padding: 0.75rem 1.25rem; border-radius: 2rem; font-weight: 600; text-decoration: none; transition: background-color 0.3s, color 0.3s; font-size: 0.9rem; white-space: nowrap; }
.btn-primary { background-color: var(--accent); color: #000000; }
.btn-primary:hover { background-color: #e0b820; }
.btn-full { width: 100%; text-align: center; justify-content: center; }
.social-link { display: flex; align-items: center; gap: 0.5rem; text-decoration: none; color: var(--text-secondary); transition: color 0.3s; font-size: 0.9rem; padding: 0.5rem 0.75rem; }
.social-link:hover { color: var(--accent); }
.hero-image { width: 100%; max-width: 300px; height: 300px; overflow: hidden; border-radius: 8px; margin: 0 auto; flex-shrink: 0; }
.hero-image img { width: 100%; height: 100%; object-fit: cover; object-position: center; display: block; transition: opacity 0.5s ease-in-out; }

/* About */
.about { padding: 3rem 0; }
.section-title { font-size: 2rem; font-weight: 700; text-align: center; margin-bottom: 0.5rem; color: var(--text-primary); line-height: 1.2; }
.section-subtitle { text-align: center; margin-bottom: 2rem; color: var(--text-secondary); font-size: 1rem; }
.about-content { max-width: 800px; margin: 0 auto; }
.about-text { font-size: 1rem; margin-bottom: 1.25rem; color: var(--text-secondary); line-height: 1.6; }

/* Skills */
.skills { padding: 3rem 0; }
.skills-carousel-wrapper { display: flex; justify-content: center; align-items: center; width: 100%; margin: 1.5rem 0; }
.skills-carousel-container { perspective: 800px; height: 280px; width: 100%; max-width: 600px; position: relative; margin: 0 auto; }
.skills-carousel { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform 0.8s ease; margin: 0 auto; }
.skill-item-3d { position: absolute; width: 120px; height: 120px; display: flex; flex-direction: column; align-items: center; justify-content: center; background-color: var(--card-bg); border-radius: 12px; box-shadow: 0 6px 12px var(--shadow); transition: transform 0.8s ease, opacity 0.8s ease; backface-visibility: hidden; border: 2px solid var(--accent); left: calc(50% - 60px); top: calc(50% - 60px); }
.skill-icon-3d { font-size: 2.25rem; color: var(--accent); margin-bottom: 0.5rem; }
.skill-name-3d { font-weight: 600; color: var(--text-primary); text-align: center; font-size: 0.8rem; }
.carousel-controls { display: flex; justify-content: center; gap: 0.75rem; margin-top: 1.5rem; }
.carousel-btn { background-color: var(--accent); color: var(--bg-primary); border: none; border-radius: 50%; width: 44px; height: 44px; font-size: 1rem; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.3s ease; box-shadow: 0 3px 6px var(--shadow); }
.carousel-btn:hover { transform: scale(1.1); background-color: #e0b820; }
.carousel-indicators { display: flex; justify-content: center; gap: 0.5rem; margin-top: 1rem; }
.indicator { width: 10px; height: 10px; border-radius: 50%; background-color: var(--text-secondary); cursor: pointer; transition: all 0.3s ease; }
.indicator.active { background-color: var(--accent); transform: scale(1.2); }

/* Portfolio */
.portfolio { padding: 3rem 0; }
.portfolio-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.5rem; }
@media (min-width: 768px) { .portfolio-grid { grid-template-columns: repeat(2, 1fr); } }
.portfolio-item { border-radius: 0.5rem; overflow: hidden; background-color: var(--card-bg); box-shadow: 0 4px 8px var(--shadow); transition: transform 0.3s, box-shadow 0.3s; display: flex; flex-direction: column; }
.portfolio-item:hover { transform: translateY(-5px); box-shadow: 0 8px 16px var(--shadow); }
.portfolio-image { height: 200px; overflow: hidden; }
.portfolio-image img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.3s; }
.portfolio-item:hover .portfolio-image img { transform: scale(1.05); }
.portfolio-content { padding: 1.25rem; flex-grow: 1; display: flex; flex-direction: column; }
.portfolio-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 0.5rem; color: var(--text-primary); cursor: pointer; line-height: 1.3; }
.portfolio-description { color: var(--text-secondary); display: none; font-size: 0.9rem; line-height: 1.5; margin-bottom: 1rem; }
.portfolio-description.active { display: block; }
.portfolio-tags { display: flex; gap: 0.5rem; margin-top: 0.75rem; flex-wrap: wrap; }
.tag { display: inline-block; padding: 0.25rem 0.5rem; border-radius: 1rem; font-size: 0.75rem; font-weight: 500; background-color: var(--accent); color: var(--bg-primary); }
.portfolio-actions { margin-top: auto; }
.portfolio-buttons { display: flex; gap: 0.5rem; margin-top: 1rem; flex-wrap: wrap; }
.portfolio-buttons button { padding: 0.5rem 0.75rem; border: none; border-radius: 4px; cursor: pointer; font-weight: 500; transition: all 0.3s ease; font-size: 0.8rem; flex: 1; min-width: 80px; }
.btn-download { background-color: #4CAF50; color: white; }
.btn-download:hover { background-color: #3e8e41; }
.btn-clone { background-color: #2196F3; color: white; }
.btn-clone:hover { background-color: #0b7dda; }
.btn-visit { background-color: #ff9800; color: white; }
.btn-visit:hover { background-color: #e68a00; }
.portfolio-more { display: flex; justify-content: center; margin-top: 2.5rem; }
.btn-more { background-color: var(--accent); color: var(--bg-primary); border: none; border-radius: 2rem; padding: 0.75rem 2rem; font-weight: 600; font-size: 1rem; cursor: pointer; transition: all 0.3s ease; display: inline-flex; align-items: center; gap: 0.5rem; text-decoration: none; }
.btn-more:hover { background-color: #e0b820; transform: translateY(-2px); box-shadow: 0 4px 12px rgba(255,215,0,0.3); }

/* Contact */
.contact { padding: 3rem 0; }
.contact-form-container { max-width: 600px; margin: 0 auto; }
.contact-form { display: flex; flex-direction: column; gap: 1.25rem; }
.form-group { display: flex; flex-direction: column; gap: 0.5rem; }
.form-group label { font-weight: 500; color: var(--text-primary); font-size: 0.9rem; }
.form-group input, .form-group textarea { padding: 0.75rem; border-radius: 0.25rem; border: 1px solid var(--border); background-color: var(--bg-primary); color: var(--text-primary); font-family: inherit; font-size: 0.9rem; transition: all 0.3s ease; width: 100%; }
.form-group input:focus, .form-group textarea:focus { outline: none; border-color: var(--accent); }

/* Footer */
.footer { padding: 2rem 0 1rem; background-color: var(--bg-primary); transition: background-color 0.3s ease; }
.footer-content { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; flex-wrap: wrap; gap: 1rem; }
.footer-info { flex: 1; min-width: 200px; }
.footer-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 0.5rem; }
.footer-subtitle { opacity: 0.8; font-size: 0.9rem; }
.footer-social { display: flex; gap: 1rem; }
.footer-social-link { font-size: 1.25rem; color: var(--text-primary); transition: color 0.3s; }
.footer-social-link:hover { color: var(--accent); }
.footer-bottom { text-align: center; padding-top: 1rem; border-top: 1px solid var(--border); opacity: 0.7; font-size: 0.8rem; }

/* ===== MEDIA QUERIES ===== */
@media (max-width: 768px) {
  .container { padding: 0 12px; }
  .nav-menu { display: none; }
  .menu-toggle { display: block; }
  .mobile-menu.active { display: flex; }
  .hero-content { flex-direction: column-reverse; text-align: center; gap: 1.5rem; }
  .hero-links { justify-content: center; }
  .hero-image { max-width: 250px; height: 250px; }
  .navbar { padding: 0.75rem 0; }
  .footer-content { flex-direction: column; text-align: center; gap: 1rem; }
  .footer-social { justify-content: center; }
  .scroll-to-top { bottom: 70px; right: 12px; }
}

@media (max-width: 576px) {
  html { font-size: 15px; }
  .hero { padding: 2rem 0; }
  .title { font-size: 1.75rem; }
  .name { font-size: 1.5rem; }
  .section-title { font-size: 1.75rem; }
  .hero-image { max-width: 220px; height: 220px; }
  .skills-carousel-container { height: 240px; }
  .skill-item-3d { width: 100px; height: 100px; left: calc(50% - 50px); top: calc(50% - 50px); }
  .skill-icon-3d { font-size: 1.75rem; }
  .portfolio-grid { grid-template-columns: 1fr; gap: 1rem; }
}

@media (max-width: 480px) {
  html { font-size: 14px; }
  .container { padding: 0 10px; }
  .hero { padding: 1.5rem 0; min-height: auto; }
  .hero-content { gap: 1rem; }
  .title { font-size: 1.5rem; }
  .name { font-size: 1.25rem; }
  .description { font-size: 0.9rem; }
  .hero-links { flex-direction: column; align-items: center; width: 100%; }
  .btn, .social-link { width: 100%; justify-content: center; margin-bottom: 0.5rem; }
  .hero-image { max-width: 200px; height: 200px; margin-bottom: 1rem; }
  .section-title { font-size: 1.5rem; }
  .section-subtitle { font-size: 0.9rem; }
  .about, .skills, .portfolio, .contact { padding: 2rem 0; }
  .skills-carousel-container { height: 200px; }
  .skill-item-3d { width: 90px; height: 90px; left: calc(50% - 45px); top: calc(50% - 45px); }
  .skill-icon-3d { font-size: 1.5rem; }
  .skill-name-3d { font-size: 0.7rem; }
  .carousel-btn { width: 40px; height: 40px; font-size: 0.9rem; }
  .portfolio-image { height: 160px; }
  .portfolio-content { padding: 1rem; }
  .portfolio-title { font-size: 1rem; }
  .portfolio-buttons { flex-direction: column; }
  .portfolio-buttons button { width: 100%; }
  .theme-toggle, .scroll-to-top { width: 44px; height: 44px; font-size: 1.1rem; bottom: 12px; right: 12px; }
  .scroll-to-top { bottom: 70px; }
}

@media (max-width: 360px) {
  html { font-size: 13px; }
  .container { padding: 0 8px; }
  .hero-image { max-width: 180px; height: 180px; }
  .title { font-size: 1.4rem; }
  .name { font-size: 1.2rem; }
  .section-title { font-size: 1.4rem; }
  .skills-carousel-container { height: 180px; }
  .skill-item-3d { width: 80px; height: 80px; left: calc(50% - 40px); top: calc(50% - 40px); }
  .skill-icon-3d { font-size: 1.4rem; }
  .portfolio-grid { grid-template-columns: 1fr; }
}

@media (min-width: 1400px) {
  .container { max-width: 1320px; }
  .portfolio-grid { grid-template-columns: repeat(2, 1fr); }
}
