/* ============================================================
   NguyenDevs · Linkbio — Main Stylesheet
   ============================================================ */

*, *::before, *::after { 
  box-sizing: border-box; 
  margin: 0; 
  padding: 0; 
  -webkit-tap-highlight-color: transparent;
}

:focus { outline: none; }

/* ── CSS Custom Properties ── */
:root {
  --bg: #0b0b0f;
  --surface: rgba(255,255,255,0.04);
  --surface-hover: rgba(255,255,255,0.08);
  --border: rgba(255,255,255,0.08);
  --border-hover: rgba(178,137,239,0.4);
  --accent: #b289ef;
  --accent2: #9661ff;
  --accent3: #d4a8ff;
  --text: #f0edf7;
  --muted: rgba(240,237,247,0.45);
  --radius: 18px;
  --radius-sm: 12px;
  --glow: 0 0 40px rgba(178,137,239,0.15);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
  position: relative;
  -webkit-overflow-scrolling: touch;
}

/* ── Dynamic Lava Mesh System (Desktop) ── */
:root {
  --color-bg1: #050508; 
  --color-bg2: #0b0b0f;
  --color-interactive: 107, 33, 168; /* Deeper Purple */
  --blending: hard-light;
}

.gradient-bg {
  width: 100vw;
  height: 100vh;
  position: fixed;
  overflow: hidden;
  background: var(--color-bg1);
  top: 0;
  left: 0;
  z-index: 0;
}

.gradients-container {
  filter: url(#goo) blur(40px);
  width: 100%;
  height: 100%;
}

.bg-orb {
  position: absolute;
  mix-blend-mode: var(--blending);
  transform-origin: center center;
  animation: lavaRise var(--dur, 30s) var(--delay, 0s) ease-in-out infinite;
  will-change: transform, opacity, border-radius;
  opacity: 0;
}

.interactive {
  position: absolute;
  background: radial-gradient(circle at center, rgba(var(--color-interactive), 0.6) 0, rgba(var(--color-interactive), 0) 50%) no-repeat;
  mix-blend-mode: var(--blending);
  width: 100%;
  height: 100%;
  top: -50%;
  left: -50%;
  opacity: 0.5;
  will-change: transform;
}

/* ── Keyframes ── */
@keyframes lavaRise {
  0% {
    transform: translateY(100vh) scale(1) rotate(0deg);
    opacity: 0;
    border-radius: 40% 60% 70% 30% / 40% 50% 60% 50%;
  }
  15% { opacity: 0.5; }
  50% {
    transform: translateY(40vh) scale(1.3) rotate(180deg);
    opacity: 0.7;
    border-radius: 60% 40% 30% 70% / 50% 30% 70% 50%;
  }
  85% { opacity: 0.4; }
  100% {
    transform: translateY(-20vh) scale(1) rotate(360deg);
    opacity: 0;
    border-radius: 40% 60% 70% 30% / 40% 50% 60% 50%;
  }
}

@keyframes moveInCircle {
  0%   { transform: rotate(0deg);   }
  100% { transform: rotate(360deg); }
}

/* ── Mobile Optimization (Dynamic permitted) ── */
@media (max-width: 1024px), screen and (max-width: 1024px) {
  .interactive { 
    display: none !important; 
  }
}

body.is-mobile .interactive {
  display: none !important;
}

html { scroll-behavior: smooth; }
@media (max-width: 1024px) { html { scroll-behavior: auto !important; } }

/* ── Layout ── */
.wrapper {
  position: relative;
  z-index: 1;
  max-width: 480px;
  margin: 0 auto;
  padding: 0 0 60px;
}

/* ── Cover ── */
.cover {
  position: relative;
  height: 220px;
  overflow: hidden;
  margin: 12px 12px 0;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  filter: brightness(0.5) saturate(1.4);
}
.cover-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(11,11,15,0) 0%,
    rgba(11,11,15,0.3) 60%,
    rgba(11,11,15,0.95) 100%
  );
}
.cover-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(178,137,239,0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(178,137,239,0.06) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: linear-gradient(to bottom, transparent, black 40%, black 60%, transparent);
}

/* ── Profile ── */
.profile {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 0 24px 0;
  margin-top: -56px;
  position: relative;
}
.avatar-wrap {
  position: relative;
  width: 108px;
  height: 108px;
  margin-bottom: 16px;
}
.avatar-ring {
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  background: conic-gradient(from 180deg, var(--accent), var(--accent2), #d4a8ff, var(--accent));
  animation: spin 6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.avatar-ring-mask {
  position: absolute;
  inset: 0px;
  border-radius: 50%;
  background: var(--bg);
}
.avatar-img {
  position: absolute;
  inset: 2px;
  border-radius: 50%;
  object-fit: cover;
  width: calc(100% - 4px);
  height: calc(100% - 4px);
}
.avatar-status {
  position: absolute;
  bottom: 4px;
  right: 4px;
  width: 16px;
  height: 16px;
  background: #22c55e;
  border: 3px solid var(--bg);
  border-radius: 50%;
  z-index: 2;
}
.avatar-status::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: inherit;
  opacity: 0;
  animation: statusPulse 4s cubic-bezier(0.4, 0, 0.2, 1) infinite;
  z-index: -1;
}
@keyframes statusPulse {
  0%   { transform: translate(-50%, -50%) scale(1);   opacity: 0.8; }
  60%  { transform: translate(-50%, -50%) scale(2.2); opacity: 0;   }
  100% { transform: translate(-50%, -50%) scale(2.2); opacity: 0;   }
}

.username {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 1.75rem;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #fff 0%, var(--accent3) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.1;
  margin-bottom: 4px;
}
.handle {
  font-size: 0.78rem;
  color: var(--accent);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 500;
  margin-bottom: 12px;
}
.bio-text {
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.65;
  max-width: 320px;
  font-weight: 300;
}
.bio-text strong {
  color: var(--text);
  font-weight: 500;
}
.bio-text a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  transition: all 0.2s ease;
}
.bio-text a:hover {
  color: var(--accent3);
  text-shadow: 0 0 8px rgba(178,137,239,0.4);
}

/* ── Stats bar ── */
.stats-bar {
  display: flex;
  gap: 1px;
  margin: 20px 24px 0;
  background: var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.stat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 8px;
  background: var(--surface);
  gap: 2px;
  transition: background 0.2s;
}
.stat:hover { background: var(--surface-hover); }
.stat-val {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  letter-spacing: -0.02em;
}
.stat-lbl {
  font-size: 0.68rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.stat-icon { font-size: 0.85rem; margin-bottom: 2px; }

/* ── Social icons ── */
.socials {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 24px 24px 0;
  flex-wrap: wrap;
}
.social-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  text-decoration: none;
  font-size: 1.05rem;
  transition: all 0.25s cubic-bezier(0.34,1.56,0.64,1);
  position: relative;
  overflow: hidden;
}
.social-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--accent2), var(--accent3));
  opacity: 0;
  transition: opacity 0.25s;
}
.social-btn:hover {
  transform: translateY(-3px) scale(1.08);
  border-color: var(--border-hover);
  color: white;
  box-shadow: 0 8px 24px rgba(150,97,255,0.3);
}
.social-btn:hover::before { opacity: 0.15; }
.social-btn svg { position: relative; z-index: 1; width: 18px; height: 18px; fill: currentColor; }

/* ── Section label ── */
.section-label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 28px 24px 12px;
  font-family: 'Syne', sans-serif;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
}
.section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── Link cards ── */
.links {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 24px;
}
.link-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  text-decoration: none;
  color: var(--text);
  transition: all 0.25s cubic-bezier(0.34,1.56,0.64,1);
  position: relative;
  overflow: hidden;
  animation: fadeUp 0.5s both;
}
.link-card:nth-child(1) { animation-delay: 0.05s; }
.link-card:nth-child(2) { animation-delay: 0.1s; }
.link-card:nth-child(3) { animation-delay: 0.15s; }
.link-card:nth-child(4) { animation-delay: 0.2s; }
.link-card:nth-child(5) { animation-delay: 0.25s; }
.link-card:nth-child(6) { animation-delay: 0.3s; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Section Divider ── */
.section-divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 32px 24px;
  opacity: 0.8;
}
.section-divider span {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, 
    transparent, 
    var(--border) 20%, 
    var(--border) 80%, 
    transparent
  );
}
.section-divider .divider-dot {
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--accent);
  position: relative;
}
.section-divider .divider-dot::after {
  content: '';
  position: absolute;
  inset: -4px;
  border: 1px solid rgba(178,137,239,0.2);
  border-radius: 50%;
}

.link-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, var(--accent2), transparent);
  opacity: 0;
  transition: opacity 0.3s;
}
.link-card:hover {
  transform: translateX(4px);
  border-color: var(--border-hover);
  box-shadow: var(--glow), -4px 0 0 var(--accent);
  background: var(--surface-hover);
}
.link-card:hover::before { opacity: 0.06; }

.link-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
  overflow: hidden;
}
.link-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 10px;
}
.link-icon-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}
.link-info {
  flex: 1;
  min-width: 0;
  position: relative;
  z-index: 1;
}
.link-title {
  font-family: 'Syne', sans-serif;
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}
.link-sub {
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.link-arrow {
  position: relative;
  z-index: 1;
  color: var(--muted);
  opacity: 0;
  transition: all 0.2s;
  transform: translateX(-6px);
  flex-shrink: 0;
}
.link-card:hover .link-arrow {
  opacity: 1;
  transform: translateX(0);
  color: var(--accent3);
}

/* ── Ko-fi special card ── */
.kofi-card {
  margin: 8px 24px 0;
  padding: 18px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255,94,91,0.25);
  background: linear-gradient(135deg, rgba(255,94,91,0.07) 0%, rgba(255,94,91,0.03) 100%);
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  color: var(--text);
  transition: all 0.25s;
  animation: fadeUp 0.5s 0.35s both;
}
.kofi-card:hover {
  border-color: rgba(255,94,91,0.5);
  box-shadow: 0 0 30px rgba(255,94,91,0.12);
  transform: translateY(-2px);
}
.kofi-icon { font-size: 1.6rem; }
.kofi-text strong {
  display: block;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 0.92rem;
}
.kofi-text span {
  font-size: 0.75rem;
  color: var(--muted);
}

/* ── TikTok Custom Profile Card ── */
.tiktok-card {
  margin: 20px 24px 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  overflow: hidden;
  transition: border-color 0.25s, box-shadow 0.25s;
  animation: fadeUp 0.5s 0.1s both;
}
.tiktok-card:hover {
  border-color: rgba(105,185,242,0.35);
  box-shadow: 0 0 32px rgba(105,185,242,0.08);
}

/* Header row: TikTok logo + label */
.tiktok-card__header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(0,0,0,0.2);
}
.tiktok-card__logo {
  color: #fff;
  display: flex;
  align-items: center;
}
.tiktok-card__platform {
  font-family: 'Syne', sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Body: avatar + info */
.tiktok-card__body {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 16px 14px;
}
.tiktok-card__avatar {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(105,185,242,0.3);
  flex-shrink: 0;
}
.tiktok-card__info { flex: 1; min-width: 0; }
.tiktok-card__name {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tiktok-card__handle {
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 8px;
}

/* Stats row */
.tiktok-card__stats {
  display: flex;
  align-items: center;
  gap: 12px;
}
.tiktok-stat {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.tiktok-stat__val {
  font-family: 'Rubik', sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  color: #fff;
  letter-spacing: -0.01em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.tiktok-stat__lbl {
  font-size: 0.62rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
  margin-top: 1px;
}
.tiktok-stat__sep {
  width: 1px;
  height: 28px;
  background: var(--border);
  align-self: center;
}

/* Follow button */
.tiktok-card__follow {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: calc(100% - 32px);
  margin: 0 16px 16px;
  padding: 10px 16px;
  border-radius: 8px;
  background: linear-gradient(135deg, #010101, #1a1a1a);
  border: 1px solid rgba(255,255,255,0.12);
  color: #fff;
  font-family: 'Syne', sans-serif;
  font-weight: 600;
  font-size: 0.82rem;
  text-decoration: none;
  letter-spacing: 0.04em;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}
.tiktok-card__follow::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, #69b9f2, #ee1d52, #69b9f2);
  background-size: 200%;
  opacity: 0;
  transition: opacity 0.3s;
}
.tiktok-card__follow:hover::before { opacity: 0.12; background-position: 100%; }
.tiktok-card__follow:hover {
  border-color: rgba(105,185,242,0.4);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(105,185,242,0.15);
}
.tiktok-card__follow svg { position: relative; z-index: 1; }
.tiktok-card__follow span { position: relative; z-index: 1; }

/* ── Footer ── */
.bio-footer {
  margin-top: 40px;
  text-align: center;
  font-size: 0.7rem;
  color: rgba(240,237,247,0.2);
  letter-spacing: 0.06em;
}
.bio-footer a {
  color: var(--accent);
  text-decoration: none;
}


/* ── Music Player ── */
.music-player {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
}

.music-toggle {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--accent3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  position: relative;
  padding: 0;
  outline: none;
  /* Fix for square artifacts on circular backdrop-filters */
  mask-image: radial-gradient(circle, white 100%, transparent 100%);
  -webkit-mask-image: -webkit-radial-gradient(circle, white 100%, transparent 100%);
}

.music-toggle:hover {
  transform: scale(1.1);
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--accent);
  box-shadow: 0 0 30px rgba(178, 137, 239, 0.3);
}

.music-icon-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Equalizer waves inside button */
.music-waves {
  display: none; /* Only show when playing */
  gap: 3.5px;
  height: 22px;
  align-items: center;
  justify-content: center;
}

.music-waves span {
  width: 3.5px;
  background: var(--accent);
  border-radius: 4px;
  box-shadow: 0 0 8px rgba(178, 137, 239, 0.5);
  transform-origin: center;
}

.music-waves span:nth-child(1) { height: 12px; animation: musicWaveInside 0.6s infinite alternate; }
.music-waves span:nth-child(2) { height: 22px; animation: musicWaveInside 0.8s infinite alternate 0.2s; }
.music-waves span:nth-child(3) { height: 16px; animation: musicWaveInside 0.7s infinite alternate 0.4s; }

@keyframes musicWaveInside {
  0%   { transform: scaleY(0.4); }
  100% { transform: scaleY(1);   }
}

.icon-muted {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  display: none; /* Based on state */
}

.icon-muted .slash-line {
  stroke: var(--accent3);
  stroke-width: 2.5;
}

/* Logic for showing icons based on state */
.music-toggle.playing {
  border-color: var(--accent);
  background: rgba(178, 137, 239, 0.12);
  color: #fff;
}
.music-toggle.playing .music-waves { display: flex; }
.music-toggle.playing .icon-muted  { display: none; }

.music-toggle.muted {
  border-color: rgba(255, 255, 255, 0.08);
  color: rgba(240, 237, 247, 0.4);
}
.music-toggle.muted .music-waves { display: none; }
.music-toggle.muted .icon-muted  { display: block; }

/* ── Responsive ── */
@media (max-width: 480px) {
  .cover { height: 190px; }
}
