/* ============================================
   CazaToy Link-in-Bio — Premium Dark Design
   Optimized for in-app browsers (TikTok, IG)
   ============================================ */

/* --- Design Tokens --- */
:root {
  --color-bg-primary: #0a0a0f;
  --color-bg-secondary: #12121a;
  --color-bg-card: rgba(255, 255, 255, 0.04);
  --color-bg-card-hover: rgba(255, 255, 255, 0.08);
  --color-accent: #ffd700;
  --color-accent-glow: rgba(255, 215, 0, 0.15);
  --color-accent-blue: #4a9eff;
  --color-text-primary: #f0f0f5;
  --color-text-secondary: rgba(240, 240, 245, 0.6);
  --color-text-muted: rgba(240, 240, 245, 0.35);
  --color-border: rgba(255, 255, 255, 0.08);
  --color-border-hover: rgba(255, 215, 0, 0.3);
  --color-whatsapp: #25d366;
  --color-meli: #ffe600;
  --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-full: 50%;
  --shadow-card: 0 2px 12px rgba(0, 0, 0, 0.3);
  --shadow-glow: 0 0 30px rgba(255, 215, 0, 0.08);
  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Reset & Base --- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-primary);
  background: var(--color-bg-primary);
  color: var(--color-text-primary);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Background gradient animation */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(255, 215, 0, 0.06), transparent 70%),
    radial-gradient(ellipse 60% 40% at 50% 120%, rgba(74, 158, 255, 0.04), transparent 60%);
  pointer-events: none;
  z-index: 0;
}

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

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

/* --- Main Container --- */
.page-wrapper {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 480px;
  padding: 0 20px;
  padding-bottom: 40px;
}

/* --- Header / Profile --- */
.profile {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 48px;
  margin-bottom: 32px;
}

.profile__avatar-ring {
  width: 108px;
  height: 108px;
  border-radius: var(--radius-full);
  padding: 3px;
  background: linear-gradient(135deg, var(--color-accent), var(--color-accent-blue));
  margin-bottom: 18px;
  animation: avatar-enter 0.6s var(--transition-smooth) both;
}

.profile__avatar {
  width: 100%;
  height: 100%;
  border-radius: var(--radius-full);
  object-fit: cover;
  border: 3px solid var(--color-bg-primary);
}

.profile__name {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
  animation: fade-up 0.5s 0.15s both;
}

.profile__badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.8rem;
  font-weight: 500;
  color: #3483FA;
  margin-bottom: 8px;
  animation: fade-up 0.5s 0.25s both;
}

.profile__badge svg {
  width: 14px;
  height: 14px;
  fill: #3483FA;
}

.profile__bio {
  font-size: 0.9rem;
  color: var(--color-text-secondary);
  text-align: center;
  line-height: 1.5;
  max-width: 320px;
  animation: fade-up 0.5s 0.35s both;
}

/* --- Categories Grid --- */
.categories {
  margin-bottom: 28px;
  animation: fade-up 0.5s 0.45s both;
}

.categories__title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--color-text-muted);
  margin-bottom: 14px;
  padding-left: 4px;
}

.categories__grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.category-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 4px 10px;
  border-radius: var(--radius-md);
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: all var(--transition-fast);
  cursor: pointer;
}

.category-card:hover,
.category-card:active {
  background: var(--color-bg-card-hover);
  border-color: var(--color-border-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

.category-card__icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--color-border);
}

.category-card__icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.category-card__label {
  font-size: 0.65rem;
  font-weight: 500;
  text-align: center;
  color: var(--color-text-secondary);
  line-height: 1.3;
}

/* --- Links Section --- */
.links {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 32px;
}

.link-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border-radius: var(--radius-md);
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: all var(--transition-smooth);
  position: relative;
  overflow: hidden;
}

.link-card::after {
  content: '';
  position: absolute;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  width: 6px;
  height: 6px;
  border-right: 2px solid var(--color-text-muted);
  border-bottom: 2px solid var(--color-text-muted);
  transform: translateY(-50%) rotate(-45deg);
  transition: all var(--transition-fast);
}

.link-card:hover,
.link-card:active {
  background: var(--color-bg-card-hover);
  border-color: var(--color-border-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

.link-card:hover::after,
.link-card:active::after {
  border-color: var(--color-accent);
  transform: translateY(-50%) rotate(-45deg) translate(2px, 2px);
}

/* Link card variants */
.link-card--featured {
  background: linear-gradient(135deg, rgba(255, 230, 0, 0.12), rgba(255, 230, 0, 0.04));
  border-color: rgba(255, 230, 0, 0.2);
  animation: fade-up 0.4s 0.5s both, shake-subtle 2.5s 2s infinite;
}

.link-card--featured:hover {
  border-color: rgba(255, 230, 0, 0.45);
  box-shadow: 0 4px 24px rgba(255, 230, 0, 0.15);
  animation-play-state: paused;
}

.link-card--whatsapp {
  background: linear-gradient(135deg, #25d366, #128c7e);
  border-color: #25d366;
  color: #fff;
  animation: fade-up 0.4s 0.8s both, shake-subtle 2.8s 2.5s infinite;
}

.link-card--whatsapp .link-card__title,
.link-card--whatsapp .link-card__subtitle {
  color: #fff;
}

.link-card--whatsapp .link-card__subtitle {
  opacity: 0.85;
}

.link-card--whatsapp::after {
  border-color: rgba(255, 255, 255, 0.5);
}

.link-card--whatsapp:hover,
.link-card--whatsapp:active {
  background: linear-gradient(135deg, #2be06e, #25d366);
  border-color: #2be06e;
  box-shadow: 0 4px 24px rgba(37, 211, 102, 0.25);
  animation-play-state: paused;
}

.link-card--whatsapp:hover::after,
.link-card--whatsapp:active::after {
  border-color: #fff;
}

.link-card--whatsapp .link-card__tag {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.link-card__icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1.3rem;
}

.link-card__icon--meli {
  background: linear-gradient(135deg, #ffe600, #e6cf00);
  border-radius: var(--radius-sm);
}

.link-card__icon--whatsapp {
  background: linear-gradient(135deg, #25d366, #128c7e);
  border-radius: var(--radius-sm);
}

.link-card__icon--store {
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.15), rgba(255, 215, 0, 0.05));
  border: 1px solid rgba(255, 215, 0, 0.2);
}

.link-card__icon--comercio {
  background: linear-gradient(135deg, rgba(74, 158, 255, 0.15), rgba(74, 158, 255, 0.05));
  border: 1px solid rgba(74, 158, 255, 0.2);
}

.link-card__content {
  flex: 1;
  min-width: 0;
  padding-right: 20px;
}

.link-card__title {
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 2px;
}

.link-card__subtitle {
  font-size: 0.75rem;
  color: var(--color-text-secondary);
  line-height: 1.3;
}

.link-card__tag {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 2px 7px;
  border-radius: 4px;
  position: absolute;
  top: 10px;
  right: 32px;
}

.link-card__tag--hot {
  background: rgba(255, 68, 68, 0.15);
  color: #ff6b6b;
}

.link-card__tag--new {
  background: rgba(37, 211, 102, 0.15);
  color: #25d366;
}

.link-card__tag--official {
  background: rgba(255, 230, 0, 0.15);
  color: #ffe600;
}

/* --- Fire animation container --- */
.fire-wrapper {
  position: relative;
  width: 100%;
  margin-top: -10px;
  margin-bottom: -8px;
  display: flex;
  justify-content: center;
  pointer-events: none;
}

.fire-svg {
  display: block;
  width: 100%;
  max-width: 480px;
  height: 55px;
  overflow: visible;
}

/* Flame tongue animations — each tongue flickers independently */
.flame-tongue {
  transform-origin: 50% 100%;
}

.ft-1 { animation: flameTongue1 1.2s ease-in-out infinite alternate; }
.ft-2 { animation: flameTongue2 0.9s ease-in-out infinite alternate; }
.ft-3 { animation: flameTongue1 1.1s ease-in-out 0.1s infinite alternate; }
.ft-4 { animation: flameTongue2 1.0s ease-in-out 0.2s infinite alternate; }
.ft-5 { animation: flameTongue1 0.8s ease-in-out infinite alternate; }
.ft-6 { animation: flameTongue2 1.15s ease-in-out 0.15s infinite alternate; }
.ft-7 { animation: flameTongue1 0.95s ease-in-out 0.3s infinite alternate; }
.ft-8 { animation: flameTongue2 1.05s ease-in-out 0.05s infinite alternate; }
.ft-9 { animation: flameTongue1 1.1s ease-in-out 0.25s infinite alternate; }

/* Back layer orange base undulates */
.flame-layer-back {
  animation: flameBase 2s ease-in-out infinite alternate;
  transform-origin: 50% 100%;
}

/* Front layer subtle sway */
.flame-layer-front {
  animation: flameSway 3s ease-in-out infinite alternate;
  transform-origin: 50% 100%;
}

.flame-layer-inner {
  animation: flameSway 2.5s ease-in-out 0.5s infinite alternate;
  transform-origin: 50% 100%;
}


/* --- Staggered Link Animations --- */
/* MeLi featured and WhatsApp have their own animation set above with shake */
.links .link-card:nth-child(2) { animation: fade-up 0.4s 0.6s both; }
.links .link-card:nth-child(4) { animation: fade-up 0.4s 0.9s both; }

.fire-wrapper { animation: fade-up 0.4s 0.65s both; }

/* --- Social Bar --- */
.social-bar {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 36px;
  animation: fade-up 0.5s 1s both;
}

.social-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  transition: all var(--transition-fast);
  color: var(--color-text-secondary);
}

.social-icon:hover,
.social-icon:active {
  background: var(--color-bg-card-hover);
  border-color: var(--color-border-hover);
  color: var(--color-accent);
  transform: translateY(-2px);
}

.social-icon svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

/* --- Footer --- */
.footer {
  text-align: center;
  padding: 20px 0;
  animation: fade-up 0.5s 1.1s both;
}

.footer__divider {
  width: 40px;
  height: 1px;
  background: var(--color-border);
  margin: 0 auto 16px;
}

.footer__brand {
  font-size: 0.7rem;
  color: var(--color-text-muted);
  line-height: 1.6;
}

.footer__brand a {
  color: var(--color-accent-blue);
  transition: color var(--transition-fast);
}

.footer__brand a:hover {
  color: var(--color-accent);
}

.footer__copy {
  font-size: 0.65rem;
  color: var(--color-text-muted);
  margin-top: 4px;
}

/* --- Animations --- */
@keyframes avatar-enter {
  from {
    opacity: 0;
    transform: scale(0.7);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

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

/* Shake animation for CTA buttons */
@keyframes shake-subtle {
  0%, 86% {
    transform: translateX(0);
  }
  88% {
    transform: translateX(-3px) rotate(-0.5deg);
  }
  90% {
    transform: translateX(3px) rotate(0.5deg);
  }
  92% {
    transform: translateX(-3px) rotate(-0.5deg);
  }
  94% {
    transform: translateX(3px) rotate(0.5deg);
  }
  96% {
    transform: translateX(-2px) rotate(-0.3deg);
  }
  98% {
    transform: translateX(1px) rotate(0.1deg);
  }
  100% {
    transform: translateX(0);
  }
}

/* Cartoon flame tongue flicker */
@keyframes flameTongue1 {
  0%   { transform: scaleY(1) scaleX(1) translateY(0); }
  30%  { transform: scaleY(1.08) scaleX(0.96) translateY(-2px); }
  60%  { transform: scaleY(0.94) scaleX(1.04) translateY(1px); }
  100% { transform: scaleY(1.06) scaleX(0.98) translateY(-1px); }
}

@keyframes flameTongue2 {
  0%   { transform: scaleY(1.04) scaleX(0.98) translateY(-1px); }
  40%  { transform: scaleY(0.92) scaleX(1.03) translateY(1px); }
  70%  { transform: scaleY(1.1) scaleX(0.95) translateY(-3px); }
  100% { transform: scaleY(0.97) scaleX(1.02) translateY(0); }
}

@keyframes flameBase {
  0%   { transform: scaleY(1) translateY(0); }
  50%  { transform: scaleY(1.03) translateY(-1px); }
  100% { transform: scaleY(0.98) translateY(1px); }
}

@keyframes flameSway {
  0%   { transform: skewX(0deg); }
  50%  { transform: skewX(0.5deg); }
  100% { transform: skewX(-0.5deg); }
}

/* --- Responsive Adjustments --- */
@media (max-width: 360px) {
  .page-wrapper {
    padding: 0 16px;
  }

  .categories__grid {
    gap: 8px;
  }

  .category-card {
    padding: 10px 2px 8px;
  }

  .category-card__icon {
    width: 38px;
    height: 38px;
  }

  .link-card {
    padding: 14px 16px;
  }
}

@media (min-width: 481px) {
  .page-wrapper {
    padding: 0 24px;
  }
}

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

/* Focus-visible for keyboard navigation */
.link-card:focus-visible,
.category-card:focus-visible,
.social-icon:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* Safe area for iPhone notch */
@supports (padding-top: env(safe-area-inset-top)) {
  .profile {
    padding-top: calc(48px + env(safe-area-inset-top));
  }

  .footer {
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
  }
}
