/* =========================================
   BASE & TYPOGRAPHY
   ========================================= */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family:
    -apple-system, BlinkMacSystemFont, "San Francisco", "Helvetica Neue",
    Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* =========================================
   VARIABLES
   ========================================= */
:root {
  --text-color: #f5f5f7;
  --text-muted: rgba(255, 255, 255, 0.7);
  --bg-gradient: linear-gradient(-45deg, #0f172a, #581c87, #1e1b4b, #0ea5e9);
  --glass-bg: rgba(20, 20, 20, 0.35);
  --glass-border: rgba(255, 255, 255, 0.1);
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
  --glass-hover: rgba(40, 40, 40, 0.45);
  --switch-track: rgba(255, 255, 255, 0.2);
  --switch-thumb-bg: #ffffff;
  --blue-verified: #0ea5e9;
  --toast-bg: #f5f5f7;
  --toast-color: #1d1d1f;
}

.light {
  --text-color: #1d1d1f;
  --text-muted: rgba(0, 0, 0, 0.6);
  --bg-gradient: linear-gradient(-45deg, #ff9a9e, #fecfef, #a1c4fd, #c2e9fb);
  --glass-bg: rgba(255, 255, 255, 0.45);
  --glass-border: rgba(255, 255, 255, 0.5);
  --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.1);
  --glass-hover: rgba(255, 255, 255, 0.65);
  --switch-track: rgba(0, 0, 0, 0.15);
  --switch-thumb-bg: #ffffff;
  --blue-verified: #007aff;
  --toast-bg: #1d1d1f;
  --toast-color: #f5f5f7;
}

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--blue-verified);
  outline-offset: 2px;
  border-radius: inherit;
}

/* =========================================
   BODY & LAYOUT
   ========================================= */
body {
  color: var(--text-color);
  background: var(--bg-gradient);
  background-size: 400% 400%;
  animation: liquidGradient 15s ease infinite;
  min-height: 100vh;
  transition: color 0.5s ease;
  position: relative;
  display: flex;
  justify-content: center;
}

@keyframes liquidGradient {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

#container {
  width: 100%;
  max-width: 420px;
  padding: 40px 24px;
  position: relative;
}

/* =========================================
   PROFILE & AVATAR
   ========================================= */
#profile {
  text-align: center;
}

#share-btn {
  position: absolute;
  top: 40px;
  right: 24px;
  width: 44px; /* Apple HIG touch target */
  height: 44px;
  border-radius: 50%;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: var(--text-color);
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  z-index: 10;
  -webkit-tap-highlight-color: transparent;
}

#share-btn:hover {
  transform: scale(1.08);
  background: var(--glass-hover);
}
#share-btn:active {
  transform: scale(0.95);
}

.avatar-glass-ring {
  width: 128px;
  height: 128px;
  margin: 0 auto;
  border-radius: 50%;
  padding: 6px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  box-shadow: var(--glass-shadow);
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  position: relative;
  overflow: hidden;
  /* Hack Safari para bordas arredondadas perfeitas ao usar overflow hidden */
  -webkit-mask-image: -webkit-radial-gradient(white, black);
}

.avatar-glass-ring:hover {
  transform: scale(1.05);
}

.image-protection-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  background: transparent;
  border-radius: 50%;
}

#profile img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  pointer-events: none;
  -webkit-user-drag: none;
  user-select: none;
  -moz-user-select: none;
  display: block;
}

.username {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -0.022em;
  margin-top: 20px;
  user-select: text;
}

.verified-badge {
  color: var(--blue-verified);
  font-size: 18px;
}

.description {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-muted);
  max-width: 85%;
  margin: 12px auto 20px;
  font-weight: 400;
  animation: appleFadeInUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) backwards;
}

/* =========================================
   LANGUAGE SELECTOR
   ========================================= */
#language-selector {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-bottom: 24px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 4px;
  border-radius: 24px;
  animation: appleFadeInUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) backwards;
  animation-delay: 0.1s;
}

.lang-btn {
  background: none;
  border: none;
  color: var(--text-color);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  opacity: 0.5;
  transition:
    opacity 0.3s ease,
    color 0.3s ease;
  padding: 8px 16px; /* Aumentado para melhor toque (Apple HIG) */
  border-radius: 20px;
  -webkit-tap-highlight-color: transparent;
}

.lang-btn.active {
  opacity: 1;
  color: var(--blue-verified);
}

.divider {
  width: 1px;
  height: 12px;
  background: var(--glass-border);
}

/* =========================================
   THEME SWITCH
   ========================================= */
#switch {
  position: relative;
  width: 64px;
  height: 32px;
  margin: 0 auto 24px;
}

#switch span {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--switch-track);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 32px;
  transition: background 0.4s ease;
}

#switch button {
  position: absolute;
  top: 2px;
  left: 2px;
  z-index: 1;
  width: 28px;
  height: 28px;
  background-color: var(--switch-thumb-bg);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.2),
    0 0 1px rgba(0, 0, 0, 0.1);
  transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
  -webkit-tap-highlight-color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
}

#switch button::before,
#switch button::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  transition:
    opacity 0.3s ease,
    transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
}

#switch button::before {
  background-image: url("./assets/moon-stars.svg");
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

#switch button::after {
  background-image: url("./assets/sun.svg");
  opacity: 0;
  transform: rotate(-90deg) scale(0.4);
}

.light #switch button {
  transform: translateX(32px);
}
.light #switch button::before {
  opacity: 0;
  transform: rotate(90deg) scale(0.4);
}
.light #switch button::after {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

/* =========================================
   LINKS LIST
   ========================================= */
ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

ul li {
  animation: appleFadeInUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) backwards;
}
ul li:nth-child(1) {
  animation-delay: 0.1s;
}
ul li:nth-child(2) {
  animation-delay: 0.15s;
}
ul li:nth-child(3) {
  animation-delay: 0.2s;
}
ul li:nth-child(4) {
  animation-delay: 0.25s;
}

ul li a {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 16px;
  padding: 16px 20px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  box-shadow: var(--glass-shadow);
  border-radius: 18px;
  text-decoration: none;
  color: var(--text-color);
  transition:
    transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1),
    background 0.3s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

ul li a > ion-icon {
  font-size: 28px;
  flex-shrink: 0;
}

.link-content {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
}
.link-content strong {
  font-weight: 500;
  font-size: 15px;
  letter-spacing: -0.01em;
  line-height: 1.2;
}
.link-content span {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.2;
}

ul li a:hover {
  background: var(--glass-hover);
  transform: scale(1.02);
}
ul li a:active {
  transform: scale(0.97);
}

/* =========================================
   SOCIAL & FOOTER
   ========================================= */
#social-links {
  display: flex;
  justify-content: center;
  gap: 16px;
  padding: 32px 0 24px;
  animation: appleFadeInUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) backwards;
  animation-delay: 0.3s;
}

#social-links a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  box-shadow: var(--glass-shadow);
  color: var(--text-color);
  font-size: 22px;
  transition:
    transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1),
    background 0.3s ease;
  -webkit-tap-highlight-color: transparent;
}

#social-links a:hover {
  background: var(--glass-hover);
  transform: translateY(-4px) scale(1.05);
}
#social-links a:active {
  transform: scale(0.95);
}

footer {
  padding: 16px 0;
  text-align: center;
  font-size: 13px;
  letter-spacing: 0.02em;
  opacity: 0.7;
  color: var(--text-color);
  animation: appleFadeInUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) backwards;
  animation-delay: 0.4s;
  user-select: none;
}

/* =========================================
   TOAST
   ========================================= */
#toast {
  position: fixed;
  bottom: -80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--toast-bg);
  color: var(--toast-color);
  padding: 14px 28px;
  border-radius: 32px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  transition: bottom 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 100;
  pointer-events: none;
}

#toast.show {
  bottom: 40px;
}

/* =========================================
   ANIMATIONS & RESPONSIVE
   ========================================= */
@keyframes appleFadeInUp {
  0% {
    opacity: 0;
    transform: translateY(20px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 380px) {
  #container {
    padding: 32px 16px;
  }
  .avatar-glass-ring {
    width: 110px;
    height: 110px;
  }
  ul li a {
    padding: 14px 16px;
    gap: 12px;
  }
  .link-content strong {
    font-size: 14px;
  }
  .link-content span {
    font-size: 12px;
  }
  #social-links {
    gap: 12px;
  }
}

@media (min-width: 768px) {
  #container {
    margin-top: 40px;
  }
  #share-btn {
    right: -32px;
    top: 40px;
  }
}

/* Acessibilidade de Sistema (HIG) */
@media (prefers-reduced-motion: reduce) {
  body {
    animation: none;
    background-position: 0% 50%;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

@media (prefers-reduced-transparency: reduce) {
  :root {
    --glass-bg: rgba(20, 20, 20, 0.9);
  }
  .light {
    --glass-bg: rgba(255, 255, 255, 0.95);
  }
  .avatar-glass-ring,
  ul li a,
  #social-links a,
  #share-btn,
  #switch span,
  #language-selector {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }
}
