/* --- CSS VARIABLES --- */
:root {
  --bg-color: #ffffff;
  --card-bg: #f8f9fa;
  --text-color: #1a1a1a;
  --text-muted: #666666;
  --accent-color: #000000;
  --border-color: #e5e7eb;
  --header-bg: rgba(255, 255, 255, 0.95);
  --shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
  --transition: all 0.3s ease-in-out;
}

body.dark-mode {
  --bg-color: #111111;
  --card-bg: #1f1f1f;
  --text-color: #ffffff;
  --text-muted: #a0a0a0;
  --accent-color: #ffffff;
  --border-color: #333333;
  --header-bg: rgba(17, 17, 17, 0.95);
  --shadow: 0 4px 15px rgba(255, 255, 255, 0.05);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  text-decoration: none;
  list-style: none;
  scroll-behavior: smooth;
}

a, button, .play-btn, #theme-toggle, #menu-icon {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.is-magnetic {
  transform: translate3d(var(--magnet-x, 0), var(--magnet-y, 0), 0);
}


body {
  font-family: "Poppins", sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  line-height: 1.6;
  overflow-x: hidden;
  transition: background-color 0.3s, color 0.3s;
}

.cursor-glow {
  --cursor-x: 50vw;
  --cursor-y: 50vh;
  position: fixed;
  left: var(--cursor-x);
  top: var(--cursor-y);
  width: 260px;
  height: 260px;
  border-radius: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(255, 126, 179, 0.18), rgba(142, 68, 173, 0.08) 42%, transparent 70%);
  mix-blend-mode: screen;
  z-index: 1;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.cursor-glow.is-visible {
  opacity: 1;
}

.cursor-trail {
  --trail-x: 50vw;
  --trail-y: 50vh;
  --trail-size: 8px;
  --trail-alpha: 0.5;
  position: fixed;
  left: var(--trail-x);
  top: var(--trail-y);
  width: var(--trail-size);
  height: var(--trail-size);
  border-radius: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%);
  background: linear-gradient(135deg, #ff7eb3, #8e44ad, #4facfe);
  box-shadow: 0 0 18px rgba(255, 126, 179, 0.45);
  opacity: 0;
  mix-blend-mode: screen;
  z-index: 10000;
  transition: opacity 0.18s ease;
}

.cursor-trail.is-visible {
  opacity: var(--trail-alpha);
}

.cursor-spark {
  position: fixed;
  left: var(--spark-x);
  top: var(--spark-y);
  width: var(--spark-size);
  height: var(--spark-size);
  border-radius: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%);
  background: color-mix(in srgb, var(--accent-color) 40%, #ff7eb3);
  box-shadow: 0 0 14px rgba(255, 126, 179, 0.6);
  z-index: 10000;
  animation: cursorSpark 0.75s ease-out forwards;
}

@keyframes cursorSpark {
  from {
    opacity: 0.8;
    transform: translate(-50%, -50%) scale(1);
  }
  to {
    opacity: 0;
    transform: translate(calc(-50% + var(--spark-dx)), calc(-50% + var(--spark-dy))) scale(0.2);
  }
}

body.project-page-transition::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at center, rgba(255, 126, 179, 0.14), transparent 42%);
  opacity: 0;
  z-index: 9998;
  animation: pagePulse 0.55s ease-out;
}

@keyframes pagePulse {
  0% {
    opacity: 0;
    transform: scale(0.96);
  }
  45% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: scale(1.04);
  }
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-color);
}

::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #555;
}

/* --- HEADER --- */
header {
  position: fixed;
  top: 0;
  width: 100%;
  padding: 15px 8%;
  background: var(--header-bg);
  backdrop-filter: blur(10px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 1000;
  border-bottom: 1px solid var(--border-color);
}

.logo {

  font-family: 'Montserrat', sans-serif;
  font-size: 22px;
  font-weight: 800;
  color: var(--text-color);
  letter-spacing: -0.5px;
  text-transform: uppercase;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 15px;
}

.navbar a {
  font-size: 14px;
  color: var(--text-color);
  margin-left: 25px;
  font-weight: 500;
  transition: var(--transition);
}

.navbar a:hover,
.navbar a.active {
  color: var(--text-muted);
}



#menu-icon {
  font-size: 22px;
  color: var(--text-color);
  display: none;
  cursor: pointer;
}

/* --- SECTIONS --- */
section {
  padding: 80px 8% 40px;
  overflow: hidden;
}

.heading {

  font-family: 'Montserrat', sans-serif;
  font-size: 32px;
  margin-bottom: 40px;
  font-weight: 700;
  position: relative;
  display: inline-block;
  letter-spacing: -1px;
}

.heading::after {
  content: '';
  position: absolute;
  width: 40%;
  height: 3px;
  background: var(--accent-color);
  bottom: -5px;
  left: 0;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.65s cubic-bezier(0.16, 1, 0.3, 1);
}

.heading.heading-in-view::after,
.heading.active::after {
  transform: scaleX(1);
}

/* --- HERO --- */
.unified-hero {
  min-height: 90vh;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3rem;
  position: relative;
  isolation: isolate;
}

.hero-particles {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: -1;
}

.hero-particles span {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent-color) 35%, transparent);
  opacity: 0.28;
  animation: particleFloat var(--duration) ease-in-out var(--delay) infinite alternate;
}

@keyframes particleFloat {
  from {
    transform: translate3d(-10px, 8px, 0) scale(0.8);
    opacity: 0.12;
  }
  to {
    transform: translate3d(18px, -22px, 0) scale(1.25);
    opacity: 0.38;
  }
}

.hero-text {
  flex: 1;
}

.hero-reveal {
  opacity: 0;
  transform: translateY(16px);
}

body.hero-ready .hero-reveal {
  animation: heroReveal 0.75s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  animation-delay: var(--reveal-delay, 0ms);
}

@keyframes heroReveal {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hero-text h1 {

  font-family: 'Montserrat', sans-serif;
  font-size: 48px;
  font-weight: 800;
  margin: 10px 0;
  line-height: 1.1;
  letter-spacing: -1px;
}

.bio {
  margin: 15px 0 25px;
  color: var(--text-muted);
  font-size: 15px;
}

/* AVATAR */
.hero-img {
  flex: 0.8;
  display: flex;
  justify-content: center;
}

.hero-img img {
  width: 320px;
  height: 320px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border-color);
  transition: transform 0.4s ease, filter 0.3s ease;
}

.hero-img img:hover {
  transform: scale(1.1);
  border-color: var(--accent-color);
}

/* --- PROJECTS --- */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  justify-content: center;
}

.project-card {
  background: var(--card-bg);
  padding: 15px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  transition: var(--transition);
  max-width: 300px;
  margin: 0 auto;
  width: 100%;
  position: relative;
  transform-style: preserve-3d;
  will-change: transform;
}

.project-card::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  opacity: 0;
  pointer-events: none;
  background: radial-gradient(circle at var(--glow-x, 50%) var(--glow-y, 50%), rgba(255, 126, 179, 0.22), transparent 38%);
  transition: opacity 0.25s ease;
}

.project-thumb {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  margin-bottom: 12px;
}

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

.project-card.is-tilting {
  transform: perspective(900px) rotateX(var(--tilt-x, 0deg)) rotateY(var(--tilt-y, 0deg)) translateY(-6px);
  box-shadow: 0 18px 35px rgba(0, 0, 0, 0.14);
}

.project-card.is-tilting::before {
  opacity: 1;
}

.project-card.project-launching {
  animation: projectLaunch 0.55s ease-out;
}

@keyframes projectLaunch {
  0% {
    transform: scale(1);
  }
  45% {
    transform: scale(0.97);
  }
  100% {
    transform: scale(1.02);
  }
}

.project-card img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  border-radius: 8px;
  filter: grayscale(20%);
  display: block;
  transition: transform 0.3s ease, filter 0.3s ease;
}

.project-card:hover img {
  filter: grayscale(0%);
  transform: scale(1.04);
}

.project-featured {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.project-card.featured-card {
  border-color: transparent;
  background:
    linear-gradient(var(--card-bg), var(--card-bg)) padding-box,
    linear-gradient(120deg, #ff7eb3, #8e44ad, #4facfe, #ff7eb3) border-box;
  background-size: 100% 100%, 300% 300%;
  animation: featuredBorder 8s linear infinite;
}

@keyframes featuredBorder {
  to {
    background-position: 0 0, 300% 0;
  }
}

.project-info h4 {
  font-size: 18px;
  margin-bottom: 5px;
  font-weight: 600;
  font-family: 'Montserrat', sans-serif;
}

.project-tech-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0 14px;
}

.project-tech {
  padding: 4px 9px;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
}

.project-btn {
  display: inline-block;
  font-size: 13px;
  font-weight: 500;
  color: var(--accent-color);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: var(--transition);
}

.project-btn:hover {
  border-bottom: 1px solid var(--accent-color);
  gap: 5px;
}

.project-btn i {
  margin-left: 5px;
  font-size: 11px;
  transition: transform 0.3s;
}

.project-btn:hover i {
  transform: translateX(3px);
}

/* --- SKILLS --- */
.skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 20px;
  text-align: center;
}

.skill-item {
  background: var(--card-bg);
  padding: 20px 10px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  position: relative; /* for tooltip */
}

.skill-item:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow);
  background: var(--bg-color);
}

.skill-item i {
  font-size: 40px;
  transition: transform 0.3s;
}

.skill-item:hover i {
  transform: scale(1.1);
}

.skill-item span {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-color);
}

/* --- TIMELINE --- */
.timeline-container {
  position: relative;
  max-width: 700px;
  margin: 0 auto;
  border-left: 2px solid var(--border-color);
  padding-left: 30px;
}

.timeline-item {
  position: relative;
  margin-bottom: 30px;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -37px;
  top: 5px;
  width: 12px;
  height: 12px;
  background: var(--bg-color);
  border: 2px solid var(--accent-color);
  border-radius: 50%;
}

.time-stamp {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
  display: block;
  margin-bottom: 5px;
}

.timeline-content h3 {
  font-size: 16px;
  margin-bottom: 3px;
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
}

.timeline-content p {
  font-size: 14px;
  color: var(--text-muted);
}

/* --- STUDY MATERIAL --- */
.study-banner {
  background: var(--card-bg);
  padding: 40px;
  text-align: center;
  border-radius: 15px;
  border: 1px solid var(--border-color);
  max-width: 600px;
  margin: 0 auto;
}

.study-banner h2 {
  font-size: 24px;
  margin-bottom: 10px;
  font-family: 'Montserrat', sans-serif;
}

.study-btn {
  display: inline-flex;
  align-items: center;
  padding: 12px 30px;
  background: var(--accent-color);
  color: var(--bg-color);
  border-radius: 50px;
  font-weight: 600;
  transition: var(--transition);
  border: 2px solid var(--accent-color);
  font-size: 14px;
}

.study-btn:hover {
  background: transparent;
  color: var(--accent-color);
}

/* --- FOREVER CLOCK --- */
.forever-clock {
  position: fixed;
  left: 24px;
  bottom: 24px;
  z-index: 920;
  display: inline-flex;
  align-items: center;
  gap: 16px;
  padding: 12px 15px;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  background:
    linear-gradient(color-mix(in srgb, var(--card-bg) 88%, transparent), color-mix(in srgb, var(--card-bg) 88%, transparent)) padding-box,
    linear-gradient(135deg, rgba(255, 126, 179, 0.65), rgba(142, 68, 173, 0.65), rgba(79, 172, 254, 0.65)) border-box;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.16);
  max-width: 100%;
  transform: translateY(0);
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
  cursor: pointer;
}

.forever-clock:hover {
  transform: translateY(-4px);
  border-color: color-mix(in srgb, #ff7eb3 60%, var(--border-color));
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.2);
}

.forever-clock:focus-visible {
  outline: 3px solid rgba(255, 126, 179, 0.35);
  outline-offset: 4px;
}

.clock-face {
  position: relative;
  width: 66px;
  height: 66px;
  border-radius: 50%;
  flex: 0 0 auto;
  background:
    radial-gradient(circle at 50% 50%, var(--card-bg) 0 57%, transparent 58%),
    conic-gradient(from 0deg, #ff7eb3, #8e44ad, #4facfe, #ff7eb3);
  box-shadow:
    inset 0 0 0 5px var(--bg-color),
    0 10px 24px rgba(0, 0, 0, 0.12);
}

.clock-face::before {
  content: '';
  position: absolute;
  inset: 9px;
  border-radius: 50%;
  border: 1px dashed color-mix(in srgb, var(--accent-color) 28%, transparent);
}

.clock-mark {
  position: absolute;
  color: var(--text-muted);
  font-family: 'Montserrat', sans-serif;
  font-size: 8px;
  font-weight: 800;
  line-height: 1;
}

.mark-12 {
  top: 7px;
  left: 50%;
  transform: translateX(-50%);
}

.mark-3 {
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
}

.mark-6 {
  bottom: 7px;
  left: 50%;
  transform: translateX(-50%);
}

.mark-9 {
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
}

.clock-hand {
  position: absolute;
  left: 50%;
  bottom: 50%;
  border-radius: 999px;
  transform-origin: 50% 100%;
  transform: translateX(-50%) rotate(0deg);
}

.hour-hand {
  width: 4px;
  height: 18px;
  background: var(--text-color);
}

.minute-hand {
  width: 3px;
  height: 24px;
  background: var(--text-muted);
}

.second-hand {
  width: 2px;
  height: 28px;
  background: #ff7eb3;
  box-shadow: 0 0 10px rgba(255, 126, 179, 0.7);
}

.clock-center {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ff7eb3, #8e44ad);
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 4px var(--card-bg);
}

.clock-orbit {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: #ff7eb3;
  border-right-color: rgba(79, 172, 254, 0.85);
  animation: foreverClockOrbit 1.8s linear infinite;
}

@keyframes foreverClockOrbit {
  to {
    transform: rotate(360deg);
  }
}

.clock-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.clock-label {
  color: #ff7eb3;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.4px;
}

.clock-copy strong {
  color: var(--text-color);
  font-family: 'Montserrat', sans-serif;
  font-size: 17px;
  line-height: 1.15;
  white-space: nowrap;
}

.clock-copy span:last-child {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
}

.clock-panel {
  position: absolute;
  left: 0;
  bottom: calc(100% + 14px);
  width: 260px;
  padding: 14px;
  border: 1px solid color-mix(in srgb, var(--border-color) 70%, #ff7eb3);
  border-radius: 16px;
  background: color-mix(in srgb, var(--card-bg) 92%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.18);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px) scale(0.96);
  transform-origin: bottom left;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.clock-panel::after {
  content: '';
  position: absolute;
  left: 30px;
  top: 100%;
  width: 14px;
  height: 14px;
  background: color-mix(in srgb, var(--card-bg) 92%, transparent);
  border-right: 1px solid color-mix(in srgb, var(--border-color) 70%, #ff7eb3);
  border-bottom: 1px solid color-mix(in srgb, var(--border-color) 70%, #ff7eb3);
  transform: translateY(-7px) rotate(45deg);
}

.forever-clock.panel-open .clock-panel {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.clock-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  color: var(--text-color);
  font-family: 'Montserrat', sans-serif;
  font-size: 14px;
  font-weight: 800;
}

.clock-panel-head button {
  width: 26px;
  height: 26px;
  border: 1px solid var(--border-color);
  border-radius: 50%;
  background: var(--bg-color);
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  transition: var(--transition);
}

.clock-panel-head button:hover {
  color: var(--text-color);
  border-color: #ff7eb3;
}

.clock-panel-note {
  margin-bottom: 10px;
  padding: 10px 11px;
  border-radius: 12px;
  border-left: 3px solid #ff7eb3;
  background: color-mix(in srgb, #ff7eb3 12%, transparent);
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.55;
}

.clock-panel-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid var(--border-color);
}

.clock-panel-row span {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
}

.clock-panel-row strong {
  color: var(--text-color);
  font-size: 12px;
  font-weight: 700;
  text-align: right;
}

/* --- FOOTER --- */
footer {
  padding: 40px 10%;
  background: var(--card-bg);
  text-align: center;
  border-top: 1px solid var(--border-color);
  margin-top: 50px;
}

.social-icons {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 10px;
}

.social-link {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  color: var(--text-color);
  font-size: 18px;
  transition: var(--transition);
}

.social-link:hover {
  background: var(--accent-color);
  color: var(--bg-color);
  border-color: var(--accent-color);
  transform: translateY(-3px);
}

footer p {
  color: var(--text-muted);
  font-size: 13px;
}

/* RESPONSIVE */
@media (max-width: 768px) {
  .unified-hero {
    flex-direction: column-reverse;
    text-align: center;
    gap: 1.5rem;
    padding-top: 100px;
    min-height: auto;
  }

  .hero-img img {
    width: 220px;
    height: 220px;
  }

  .hero-text h1 {
    font-size: 34px;
    line-height: 1.2;
  }

  .heading {
    font-size: 26px;
    margin-bottom: 25px;
  }

  .bio {
    font-size: 14px;
  }

  .navbar {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: var(--bg-color);
    flex-direction: column;
    padding: 15px 0;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
  }

  .navbar a {
    margin: 5px 0;
    padding: 12px;
    font-size: 16px;
    text-align: center;
    display: block;
    width: 100%;
  }

  .navbar.active {
    display: flex;
  }

  #menu-icon {
    display: block;
  }

  section {
    padding: 50px 5% 30px;
  }
}


/* ANIMATION CLASSES */
.animate-scroll {
  opacity: 0;
  transition: all 1s ease-out;
  transition-delay: var(--scroll-delay, 0ms);
  filter: blur(5px);
  will-change: opacity, transform, filter;
}

.from-left {
  transform: translateX(-50px);
}

.from-right {
  transform: translateX(50px);
}

.from-bottom {
  transform: translateY(50px);
}

.from-top {
  transform: translateY(-30px);
}

.animate-scroll.active {
  opacity: 1;
  transform: translate(0, 0);
  filter: blur(0);
}

/* === CSS MUSIC WIDGET (BẢN TO & RÕ CHỮ) === */
.music-widget {
  /* Tăng độ đậm nền để chữ nổi hơn (kính mờ tối màu) */
  background: rgba(20, 20, 20, 0.7);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  /* Hỗ trợ Safari */

  /* Viền sáng hơn chút để tạo khối */
  border: 1px solid rgba(255, 255, 255, 0.15);

  /* Bo tròn & Kích thước to hơn */
  border-radius: 60px;
  padding: 15px 25px;
  /* Tăng khoảng cách lề */

  display: flex;
  align-items: center;
  width: fit-content;
  min-width: 380px;
  /* Kéo dài chiều ngang ra */
  max-width: 100%;
  margin-bottom: 35px;

  /* Đổ bóng đậm hơn để widget "bay" lên khỏi nền */
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);
  transition: all 0.3s ease;
}

.music-widget:hover {
  background: rgba(30, 30, 30, 0.9);
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-3px);
}

/* Ảnh bìa (To hơn) */
.album-wrapper {
  width: 70px;
  /* Tăng từ 55px -> 70px */
  height: 70px;
  margin-right: 20px;
  flex-shrink: 0;
  position: relative;
}

.cover {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid rgba(255, 255, 255, 0.2);

  /* Animation xoay */
  animation: rotateCover 10s linear infinite;
  animation-play-state: paused;
}

.music-widget.playing .cover {
  animation-play-state: running;
}

@keyframes rotateCover {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

/* Phần chữ (Chỉnh lại cho rõ) */
.info {
  flex-grow: 1;
  padding-right: 15px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.music-widget .tag {
  font-size: 10px;
  /* To hơn xíu */
  font-weight: 800;
  color: #ff7eb3;
  /* Màu hồng neon */
  letter-spacing: 1.5px;
  margin-bottom: 4px;
  text-transform: uppercase;
  text-shadow: 0 0 10px rgba(255, 126, 179, 0.4);
  /* Phát sáng nhẹ */
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.music-visualizer {
  display: inline-flex;
  align-items: end;
  gap: 2px;
  height: 12px;
}

.music-visualizer span {
  width: 3px;
  height: 5px;
  border-radius: 999px;
  background: currentColor;
  opacity: 0.45;
  transform-origin: bottom;
}

.music-widget.playing .music-visualizer span {
  animation: visualizerBeat 0.8s ease-in-out infinite;
}

.music-widget.playing .music-visualizer span:nth-child(2) {
  animation-delay: 0.12s;
}

.music-widget.playing .music-visualizer span:nth-child(3) {
  animation-delay: 0.24s;
}

.music-widget.playing .music-visualizer span:nth-child(4) {
  animation-delay: 0.36s;
}

@keyframes visualizerBeat {
  0%, 100% {
    transform: scaleY(0.55);
    opacity: 0.45;
  }
  50% {
    transform: scaleY(1.8);
    opacity: 1;
  }
}

.music-widget .title {
  font-size: 16px;
  /* Tăng cỡ chữ tên bài hát */
  font-weight: 700;
  color: #ffffff;
  /* Trắng tinh */
  margin: 0 0 2px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
  /* Thêm bóng đen dưới chữ để nổi bần bật trên nền bất kỳ */
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}

.music-widget .artist {
  font-size: 12px;
  color: #e0e0e0;
  /* Xám sáng hơn để dễ đọc */
  font-weight: 500;
}

/* --- NÚT PLAY (To hơn & Cute) --- */
.play-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, #ff7eb3 0%, #8e44ad 100%);
  box-shadow: 0 5px 15px rgba(255, 117, 140, 0.4);
  display: flex;
  justify-content: center;
  align-items: center;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  flex-shrink: 0;
}

/* --- MUSIC CONTROLS --- */
.controls-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.prev-btn, .next-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 14px;
}

.prev-btn:hover, .next-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: scale(1.1);
  border-color: #ff7eb3;
}

.play-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 8px 25px rgba(255, 117, 140, 0.7);
}

.play-btn:active {
  transform: scale(0.95);
}

.icon-play {
  width: 0;
  height: 0;
  border-top: 9px solid transparent;
  border-bottom: 9px solid transparent;
  border-left: 16px solid #fff;
  /* Icon to hơn */
  margin-left: 5px;
}

.icon-pause {
  width: 14px;
  height: 18px;
  border-left: 5px solid #fff;
  border-right: 5px solid #fff;
  display: none;
}

.music-widget.playing .icon-play {
  display: none;
}

.music-widget.playing .icon-pause {
  display: block;
}

/* Mobile */
@media (max-width: 768px) {
  .music-widget {
    min-width: unset;
    width: 100%;
    border-radius: 25px;
    padding: 12px 15px;
    border: 1px solid rgba(255, 255, 255, 0.1);
  }

  .album-wrapper {
    width: 55px;
    height: 55px;
    margin-right: 15px;
  }

  .music-widget .title {
    max-width: 140px;
    font-size: 14px;
  }

  .music-widget .artist {
    font-size: 11px;
  }

  .play-btn {
    width: 45px;
    height: 45px;
  }

  .prev-btn, .next-btn {
    width: 32px;
    height: 32px;
    font-size: 12px;
  }

  .controls-wrapper {
    gap: 8px;
  }

  .icon-play {
    border-left: 14px solid #fff;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
  }
}

/* ============================================================
   NEW FEATURES
   ============================================================ */

/* --- DARK / LIGHT MODE TOGGLE --- */
#theme-toggle {
  cursor: pointer;
  width: 44px;
  height: 24px;
  background: var(--border-color);
  border-radius: 50px;
  position: relative;
  transition: background 0.3s;
  flex-shrink: 0;
}

#theme-toggle::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  background: var(--text-color);
  border-radius: 50%;
  top: 3px;
  left: 3px;
  transition: transform 0.3s, background 0.3s;
}

body.dark-mode #theme-toggle {
  background: #555;
}

body.dark-mode #theme-toggle::after {
  transform: translateX(20px);
}

/* toggle icon inside */
#theme-toggle i {
  position: absolute;
  font-size: 11px;
  top: 50%;
  transform: translateY(-50%);
  transition: opacity 0.3s;
  pointer-events: none;
}
#theme-toggle .icon-sun { right: 5px; opacity: 1; color: #f5a623; }
#theme-toggle .icon-moon { left: 5px; opacity: 0; color: #fff; }

body.dark-mode #theme-toggle .icon-sun { opacity: 0; }
body.dark-mode #theme-toggle .icon-moon { opacity: 1; }

/* --- SCROLL TO TOP BUTTON --- */
#scroll-top {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent-color);
  color: var(--bg-color);
  border: none;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.3s, transform 0.3s;
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

#scroll-top.visible {
  opacity: 1;
  transform: translateY(0);
}

#scroll-top:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.3);
}

/* --- PROJECT FILTER TABS --- */
.project-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.filter-btn {
  padding: 6px 18px;
  border-radius: 50px;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  font-family: 'Poppins', sans-serif;
}

.filter-btn:hover,
.filter-btn.active {
  background: var(--accent-color);
  color: var(--bg-color);
  border-color: var(--accent-color);
}

.project-card.hidden {
  display: none;
}

.project-count {
  min-height: 20px;
  margin-bottom: 18px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
}

/* --- VISITOR COUNTER --- */
.visitor-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

/* --- COPY EMAIL BUTTON --- */
.copy-email-btn {
  background: none;
  cursor: pointer;
  color: var(--text-color);
  font-size: 18px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  position: relative;
}

.copy-email-btn:hover {
  background: var(--accent-color);
  color: var(--bg-color);
  border-color: var(--accent-color);
  transform: translateY(-3px);
}

.copy-email-btn .tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) scale(0.8);
  background: var(--accent-color);
  color: var(--bg-color);
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 20px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  font-family: 'Poppins', sans-serif;
}

.copy-email-btn.copied .tooltip {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

/* ============================================================
   NEW FEATURES V2
   ============================================================ */

/* --- READING PROGRESS BAR --- */
#reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, #ff7eb3, #8e44ad);
  z-index: 9999;
  transition: width 0.1s linear;
}

/* --- TYPING CURSOR --- */
.typing-cursor {
  display: inline-block;
  animation: blink 0.7s step-end infinite;
  font-weight: 300;
  opacity: 0.7;
  margin-left: 2px;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* --- PROJECT SEARCH BOX --- */
.project-search-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  max-width: 340px;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 50px;
  padding: 8px 18px;
  transition: var(--transition);
}

.clear-search-btn {
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  transition: var(--transition);
}

.clear-search-btn.visible {
  display: flex;
}

.clear-search-btn:hover {
  background: var(--border-color);
  color: var(--text-color);
}

.project-search-wrap:focus-within {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(0,0,0,0.07);
}

.project-search-wrap i {
  color: var(--text-muted);
  font-size: 13px;
  flex-shrink: 0;
}

#projectSearch {
  border: none;
  outline: none;
  background: transparent;
  font-family: 'Poppins', sans-serif;
  font-size: 13px;
  color: var(--text-color);
  width: 100%;
}

#projectSearch::placeholder {
  color: var(--text-muted);
}

.project-empty-state {
  border: 1px dashed var(--border-color);
  border-radius: 12px;
  padding: 32px 20px;
  text-align: center;
  color: var(--text-muted);
  background: var(--card-bg);
}

.project-empty-state i {
  font-size: 34px;
  margin-bottom: 12px;
}

.project-empty-state h3 {
  color: var(--text-color);
  font-family: 'Montserrat', sans-serif;
  font-size: 18px;
  margin-bottom: 6px;
}

.project-empty-state p {
  font-size: 13px;
}

.skill-item::before {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) scale(0.85);
  background: var(--accent-color);
  color: var(--bg-color);
  font-size: 11px;
  font-family: 'Poppins', sans-serif;
  padding: 5px 12px;
  border-radius: 20px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 10;
}

.skill-item:hover::before {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

/* ============================================================
   MOBILE OPTIMIZATION (max-width: 768px)
   ============================================================ */
@media (max-width: 768px) {

  /* --- Hero H1: typing text xuống dòng riêng, không tràn --- */
  .hero-text h1 {
    font-size: 28px;
    line-height: 1.3;
    word-break: break-word;
  }

  .hero-text h1 .typing-cursor {
    display: inline;
  }

  /* --- Avatar nhỏ hơn chút --- */
  .hero-img img {
    width: 180px;
    height: 180px;
  }

  /* --- Project Search: full width --- */
  .project-search-wrap {
    max-width: 100%;
  }

  /* --- Project Filters: scroll ngang không wrap --- */
  .project-filters {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
  }

  .project-filters::-webkit-scrollbar {
    display: none;
  }

  .filter-btn {
    flex-shrink: 0;
    padding: 7px 16px;
  }

  /* --- Scroll to Top: nhỏ hơn, xa edge hơn để không đè cử chỉ iOS --- */
  #scroll-top {
    bottom: 20px;
    right: 16px;
    width: 40px;
    height: 40px;
    font-size: 15px;
  }

  /* --- Skill tooltip: dùng :active thay :hover cho touch --- */
  .skill-item:active::before {
    opacity: 1;
    transform: translateX(-50%) scale(1);
  }

  /* --- Tooltip vị trí: đảm bảo không bị cắt bởi edge screen --- */
  .skill-item::before {
    font-size: 10px;
    padding: 4px 10px;
    bottom: calc(100% + 6px);
  }

  /* --- Timeline: giảm padding --- */
  .timeline-container {
    padding-left: 20px;
  }

  .timeline-item::before {
    left: -27px;
  }

  /* --- Study banner: padding nhỏ hơn --- */
  .study-banner {
    padding: 24px 20px;
  }

  .forever-clock {
    display: none;
  }

  /* --- Footer social icons: to hơn cho ngón tay --- */
  .social-link,
  .copy-email-btn {
    width: 46px;
    height: 46px;
    font-size: 20px;
  }

  /* --- Visitor badge: wrap text --- */
  .visitor-badge {
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
  }

  /* --- Disable blur animation trên mobile (tiết kiệm pin + smoother) --- */
  .animate-scroll {
    filter: none !important;
  }

  /* --- Reading progress: dày thêm chút trên touch --- */
  #reading-progress {
    height: 4px;
  }

  /* --- Section padding --- */
  section {
    padding: 60px 4% 30px;
  }
}

/* ============================================================
   SMALL PHONE (max-width: 400px)
   ============================================================ */
@media (max-width: 400px) {
  .hero-text h1 {
    font-size: 24px;
  }

  .logo {
    font-size: 18px;
  }

  .music-widget .title {
    max-width: 110px;
    font-size: 13px;
  }

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

  .social-icons {
    gap: 12px;
  }
}

body .is-magnetic {
  transform: translate3d(var(--magnet-x, 0), var(--magnet-y, 0), 0);
}

@media (max-width: 768px) {
  .cursor-glow {
    display: none;
  }

  .hero-particles span {
    opacity: 0.18;
  }

  .project-card,
  .project-card:hover,
  .project-card.is-tilting {
    transform: none;
  }

  .project-card::before {
    display: none;
  }

  .project-card {
    max-width: 100%;
    border-radius: 10px;
  }

  .project-thumb,
  .project-card img {
    border-radius: 7px;
  }

  .project-tech-list {
    gap: 5px;
  }

  .music-visualizer {
    height: 10px;
  }

  body .is-magnetic {
    transform: none;
  }
}

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

  .hero-particles,
  .cursor-glow {
    display: none !important;
  }
}


