/* ==============================
   CSS Variables and Reset
================================= */
:root {
  --primary: #1769e0;
  --primary-dark: #0f4fb0;
  --primary-soft: #eaf2ff;
  --accent: #14b8a6;
  --bg: #f7faff;
  --surface: #ffffff;
  --surface-alt: #eef5ff;
  --text: #132033;
  --muted: #5f6f86;
  --border: #d9e4f2;
  --shadow: 0 20px 50px rgba(23, 105, 224, 0.12);
  --radius: 8px;
  --header-height: 76px;
  --transition: 180ms ease;
}

body.dark-mode {
  --primary: #62a8ff;
  --primary-dark: #8ec1ff;
  --primary-soft: #102a4d;
  --accent: #2dd4bf;
  --bg: #0d1320;
  --surface: #121b2b;
  --surface-alt: #172338;
  --text: #ecf4ff;
  --muted: #b7c5d8;
  --border: #293a55;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.28);
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: var(--header-height);
}

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Inter, Roboto, Arial, sans-serif;
  line-height: 1.6;
  transition: background var(--transition), color var(--transition);
}

body.modal-open {
  overflow: hidden;
}

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

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

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--primary) 62%, white);
  outline-offset: 3px;
}

/* ==============================
   Reusable Layout
================================= */
.container {
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto;
}

.narrow {
  width: min(860px, calc(100% - 40px));
}

.section {
  padding: 96px 0;
}

.section-heading {
  max-width: 680px;
  margin-bottom: 36px;
}

.section-heading h2,
.contact-info h2 {
  color: var(--text);
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.15;
}

.section-kicker {
  margin-bottom: 12px;
  color: var(--primary);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 12px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-weight: 700;
  transition: transform var(--transition), border-color var(--transition), background var(--transition), color var(--transition);
}

.btn:hover,
.btn:focus-visible {
  transform: translateY(-2px);
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 14px 24px rgba(23, 105, 224, 0.22);
}

.btn-primary:hover,
.btn-primary:focus-visible {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--border);
  color: var(--primary);
}

.btn-ghost {
  background: transparent;
  border-color: var(--primary);
  color: var(--primary);
}

/* ==============================
   Header and Navigation
================================= */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(16px);
}

.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1120px, calc(100% - 40px));
  min-height: var(--header-height);
  margin: 0 auto;
}

.brand {
  color: var(--text);
  font-size: 1.18rem;
  font-weight: 800;
}

.nav-menu {
  display: flex;
  align-items: center;
  gap: 8px;
  list-style: none;
}

.nav-link {
  display: inline-flex;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--muted);
  font-weight: 700;
  transition: background var(--transition), color var(--transition);
}

.nav-link:hover,
.nav-link:focus-visible,
.nav-link.active {
  background: var(--primary-soft);
  color: var(--primary);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  order: 3;
}

.theme-toggle,
.menu-toggle {
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  transition: background var(--transition), border-color var(--transition), color var(--transition), transform var(--transition);
}

.theme-toggle:hover,
.menu-toggle:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
}

.theme-toggle {
  position: relative;
  display: inline-grid;
  place-items: center;
  overflow: hidden;
}

.theme-icon {
  position: absolute;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: opacity var(--transition), transform var(--transition);
}

.icon-sun {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

.icon-moon {
  opacity: 0;
  transform: rotate(-35deg) scale(0.65);
}

body.dark-mode .icon-sun {
  opacity: 0;
  transform: rotate(35deg) scale(0.65);
}

body.dark-mode .icon-moon {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

.menu-toggle {
  display: none;
  place-items: center;
  gap: 4px;
  padding: 9px;
}

.menu-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text);
  transition: transform var(--transition), opacity var(--transition);
}

.menu-toggle.open span:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}

.menu-toggle.open span:nth-child(2) {
  opacity: 0;
}

.menu-toggle.open span:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

/* ==============================
   Hero Section
================================= */
.hero {
  position: relative;
  overflow: hidden;
  min-height: calc(100vh - var(--header-height));
  display: flex;
  align-items: center;
  padding: 84px 0 96px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--primary-soft) 72%, transparent), transparent 46%),
    var(--bg);
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(color-mix(in srgb, var(--primary) 10%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--primary) 10%, transparent) 1px, transparent 1px);
  background-size: 52px 52px;
  mask-image: linear-gradient(to bottom, black, transparent 76%);
  opacity: 0.55;
  pointer-events: none;
}

.hero-orbit {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.hero-orbit span {
  position: absolute;
  display: block;
  border-radius: 999px;
  background: color-mix(in srgb, var(--primary) 22%, transparent);
  filter: blur(1px);
  animation: drift 12s ease-in-out infinite;
}

.hero-orbit span:nth-child(1) {
  width: 88px;
  height: 88px;
  top: 16%;
  left: 9%;
}

.hero-orbit span:nth-child(2) {
  width: 140px;
  height: 140px;
  right: 8%;
  bottom: 18%;
  animation-delay: -4s;
}

.hero-orbit span:nth-child(3) {
  width: 54px;
  height: 54px;
  right: 36%;
  top: 18%;
  background: color-mix(in srgb, var(--accent) 28%, transparent);
  animation-delay: -7s;
}

.hero-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(280px, 0.88fr);
  align-items: center;
  gap: 54px;
}

.hero h1 {
  max-width: 760px;
  color: var(--text);
  font-size: clamp(2.8rem, 7vw, 5.4rem);
  line-height: 1.02;
}

.hero-subtitle {
  margin-top: 18px;
  color: var(--primary);
  font-size: clamp(1rem, 2vw, 1.28rem);
  font-weight: 800;
}

.hero-description {
  max-width: 620px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 1.08rem;
}

.hero-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 30px;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  max-width: 500px;
  margin-top: 28px;
}

.hero-stats div {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  padding: 14px;
  box-shadow: 0 12px 28px rgba(17, 32, 51, 0.06);
}

.hero-stats strong {
  display: block;
  color: var(--primary);
  font-size: 1.4rem;
  line-height: 1;
}

.hero-stats span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.hero-visual {
  display: flex;
  justify-content: center;
}

.profile-card {
  position: relative;
  width: min(360px, 100%);
  aspect-ratio: 1 / 1.08;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: linear-gradient(145deg, var(--primary-soft), var(--surface));
  box-shadow: var(--shadow);
  animation: floatCard 5.5s ease-in-out infinite;
}

.profile-image {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-image:not([src]),
.profile-image[src=""] {
  display: none;
}

.profile-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--primary);
  font-size: clamp(4rem, 12vw, 7rem);
  font-weight: 900;
}

.floating-badge {
  position: absolute;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  border: 1px solid color-mix(in srgb, var(--surface) 70%, transparent);
  border-radius: 18px;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  color: var(--primary);
  font-weight: 900;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  animation: badgeFloat 4.5s ease-in-out infinite;
}

.badge-icon {
  width: 34px;
  height: 34px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.badge-code {
  left: -26px;
  bottom: 72px;
}

.badge-chart {
  right: -20px;
  top: 78px;
  color: var(--accent);
  animation-delay: -1.8s;
}

/* ==============================
   About Section
================================= */
.about {
  background: var(--surface);
}

.about-text {
  color: var(--muted);
  font-size: 1.12rem;
}

/* ==============================
   Skills Section
================================= */
.skills-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.skill-card {
  position: relative;
  overflow: hidden;
  min-height: 84px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-weight: 800;
  padding: 18px;
  box-shadow: 0 12px 26px rgba(17, 32, 51, 0.05);
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.skill-icon {
  position: relative;
  z-index: 1;
  display: block;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  color: #ffffff;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  padding: 8px;
}

.skill-card > :not(.skill-icon) {
  position: relative;
  z-index: 1;
}

.html-icon { background: #e34f26; }
.css-icon { background: #1572b6; }
.js-icon { background: #d7a900; }
.php-icon { background: #6472a8; }
.mysql-icon { background: #00758f; }
.java-icon { background: #e76f00; }
.git-icon { background: #24292f; }
.xampp-icon { background: #fb7a24; }
.android-icon { background: #3ddc84; color: #123120; }
.trading-icon { background: var(--accent); }

.skill-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent, color-mix(in srgb, var(--primary) 18%, transparent), transparent);
  transform: translateX(-120%);
  transition: transform 520ms ease;
}

.skill-card:hover {
  transform: translateY(-4px);
  border-color: var(--primary);
  box-shadow: var(--shadow);
}

.skill-card:hover::before {
  transform: translateX(120%);
}

/* ==============================
   Projects Section
================================= */
.projects {
  background: var(--surface);
}

.projects-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.project-card {
  position: relative;
  overflow: hidden;
  min-height: 290px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  padding: 24px;
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
  transform-style: preserve-3d;
}

.project-card:hover {
  transform: translateY(-5px);
  border-color: var(--primary);
  box-shadow: var(--shadow);
}

.project-card-wide {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(260px, 0.9fr) minmax(0, 1.1fr);
  align-items: center;
}

.project-card h3 {
  margin-bottom: 12px;
  color: var(--text);
  font-size: 1.22rem;
  line-height: 1.3;
}

.project-image {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-alt);
  transition: transform 500ms ease, filter 500ms ease;
}

.project-card:hover .project-image {
  transform: scale(1.035);
  filter: saturate(1.12) contrast(1.04);
}

.project-card p {
  color: var(--muted);
}

.tech-list {
  color: var(--primary);
  font-size: 0.94rem;
  font-weight: 800;
}

.card-link {
  align-self: flex-start;
  display: inline-flex;
  border: 0;
  padding: 9px 13px;
  border-radius: var(--radius);
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 800;
  transition: background var(--transition), color var(--transition);
}

.card-link:hover,
.card-link:focus-visible {
  background: var(--primary);
  color: #ffffff;
}

/* ==============================
   Experience Section
================================= */
.experience {
  background: var(--bg);
}

.timeline-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}

.timeline-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 24px;
  box-shadow: 0 12px 28px rgba(17, 32, 51, 0.05);
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.timeline-card:hover {
  transform: translateY(-4px);
  border-color: var(--primary);
  box-shadow: var(--shadow);
}

.timeline-label {
  display: inline-flex;
  margin-bottom: 14px;
  border-radius: var(--radius);
  background: var(--primary-soft);
  color: var(--primary);
  padding: 6px 10px;
  font-size: 0.82rem;
  font-weight: 900;
}

.timeline-card h3 {
  margin-bottom: 10px;
  font-size: 1.15rem;
}

.timeline-card p {
  color: var(--muted);
}

/* ==============================
   Contact Section
================================= */
.contact-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(320px, 1.1fr);
  gap: 36px;
  align-items: start;
}

.contact-info > p:not(.section-kicker) {
  margin-top: 16px;
  color: var(--muted);
}

.contact-list {
  display: grid;
  gap: 14px;
  margin-top: 28px;
  list-style: none;
}

.contact-list li {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.contact-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  background: var(--primary-soft);
  color: var(--primary);
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  padding: 10px;
}

.contact-list span {
  display: block;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.contact-list a {
  color: var(--primary);
  font-weight: 800;
  overflow-wrap: anywhere;
}

.contact-form {
  display: grid;
  gap: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 26px;
  box-shadow: var(--shadow);
}

.form-field {
  display: grid;
  gap: 8px;
}

.form-field label {
  color: var(--text);
  font-weight: 800;
}

.form-field input,
.form-field textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  padding: 13px 14px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-field textarea {
  resize: vertical;
}

.form-field input:focus,
.form-field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 18%, transparent);
}

.form-field.invalid input,
.form-field.invalid textarea {
  border-color: #d92d20;
}

.error-message {
  min-height: 18px;
  color: #d92d20;
  font-size: 0.84rem;
}

.form-button {
  width: 100%;
}

.form-success {
  min-height: 22px;
  color: var(--accent);
  font-weight: 800;
  text-align: center;
}

/* ==============================
   Project Modal
================================= */
.project-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.project-modal.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(7, 12, 23, 0.62);
  backdrop-filter: blur(8px);
}

.modal-panel {
  position: relative;
  width: min(620px, 100%);
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  padding: 30px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.32);
  transform: translateY(18px) scale(0.98);
  transition: transform var(--transition);
}

.project-modal.open .modal-panel {
  transform: translateY(0) scale(1);
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
}

.modal-close-icon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.modal-panel h2 {
  margin-right: 42px;
  font-size: clamp(1.6rem, 4vw, 2.3rem);
  line-height: 1.15;
}

.modal-panel > p:not(.section-kicker) {
  margin-top: 16px;
  color: var(--muted);
}

.modal-meta {
  margin: 22px 0;
  border-left: 4px solid var(--primary);
  background: var(--bg);
  padding: 14px 16px;
}

.modal-meta span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
  text-transform: uppercase;
}

.modal-meta p {
  margin-top: 4px;
  color: var(--text);
  font-weight: 800;
}

/* ==============================
   Footer
================================= */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 26px 0;
  text-align: center;
}

.site-footer p {
  color: var(--muted);
  font-size: 0.95rem;
}

/* ==============================
   Scroll Reveal Animation
================================= */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 600ms ease, transform 600ms ease;
  transition-delay: var(--reveal-delay, 0ms);
}

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

@keyframes drift {
  0%,
  100% {
    transform: translate3d(0, 0, 0) scale(1);
  }
  50% {
    transform: translate3d(22px, -28px, 0) scale(1.08);
  }
}

@keyframes floatCard {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-14px);
  }
}

@keyframes badgeFloat {
  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(-12px) rotate(3deg);
  }
}

/* ==============================
   Responsive Design
================================= */
@media (max-width: 900px) {
  .section {
    padding: 76px 0;
  }

  .hero-grid,
  .contact-grid {
    grid-template-columns: 1fr;
  }

  .hero {
    min-height: auto;
    padding-top: 72px;
  }

  .hero-visual {
    justify-content: flex-start;
  }

  .profile-card {
    width: min(320px, 100%);
  }

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

  .timeline-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .navbar {
    flex-wrap: wrap;
  }

  .menu-toggle {
    display: grid;
  }

  .nav-menu {
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    display: grid;
    gap: 4px;
    padding: 16px 20px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    box-shadow: var(--shadow);
    transform: translateY(-140%);
    opacity: 0;
    pointer-events: none;
    transition: transform var(--transition), opacity var(--transition);
  }

  .nav-menu.open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }

  .nav-link {
    width: 100%;
    justify-content: center;
    padding: 13px;
  }

  .hero-buttons {
    align-items: stretch;
    flex-direction: column;
  }

  .hero-stats {
    grid-template-columns: 1fr;
  }

  .hero-buttons .btn {
    width: 100%;
  }

  .skills-grid,
  .projects-grid {
    grid-template-columns: 1fr;
  }

  .project-card-wide {
    grid-column: auto;
    display: flex;
  }

  .project-card {
    min-height: 250px;
  }
}

@media (max-width: 480px) {
  .container,
  .narrow,
  .navbar {
    width: min(100% - 28px, 1120px);
  }

  .section {
    padding: 64px 0;
  }

  .hero {
    padding: 58px 0 70px;
  }

  .contact-form {
    padding: 20px;
  }

  .floating-badge {
    width: 58px;
    height: 58px;
    border-radius: 14px;
  }

  .modal-panel {
    padding: 24px 20px;
  }
}

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