:root {
  --bg: #d9eef8;
  --bg-deep: #c5e4f4;
  --card: rgba(255, 252, 255, 0.82);
  --card-border: rgba(91, 184, 224, 0.35);
  --ink: #2f4558;
  --muted: rgba(47, 69, 88, 0.68);
  --accent: #5bb8e0;
  --accent-2: #f2a0b8;
  --accent-soft: rgba(91, 184, 224, 0.18);
  --glow: rgba(91, 184, 224, 0.35);
  --shield: #e85d5d;
  --gold: #d4a84b;
  --font-display: "Fredoka", "Segoe UI", sans-serif;
  --font-body: "Nunito", "Segoe UI", sans-serif;
  color-scheme: light;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  overflow-x: hidden;
}

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

.fx {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

#particles {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.wash {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(900px 520px at 50% -8%, rgba(255, 255, 255, 0.85), transparent 58%),
    radial-gradient(700px 480px at 88% 78%, rgba(242, 160, 184, 0.22), transparent 55%),
    radial-gradient(620px 420px at 8% 72%, rgba(91, 184, 224, 0.28), transparent 52%),
    linear-gradient(180deg, #eaf7fd 0%, #d5eef8 45%, #c8e6f5 100%);
}

.clouds {
  position: absolute;
  inset: -10% 0 0;
  background:
    radial-gradient(ellipse 180px 70px at 12% 18%, rgba(255, 255, 255, 0.75), transparent 70%),
    radial-gradient(ellipse 220px 80px at 78% 14%, rgba(255, 255, 255, 0.7), transparent 70%),
    radial-gradient(ellipse 160px 60px at 42% 8%, rgba(255, 255, 255, 0.65), transparent 70%),
    radial-gradient(ellipse 200px 75px at 60% 88%, rgba(255, 255, 255, 0.55), transparent 70%),
    radial-gradient(ellipse 140px 55px at 18% 84%, rgba(255, 255, 255, 0.5), transparent 70%);
  animation: cloud-drift 22s ease-in-out infinite alternate;
  opacity: 0.9;
}

.vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(120, 170, 200, 0.18) 100%);
}

@keyframes cloud-drift {
  from {
    transform: translate3d(-1.5%, 0, 0) scale(1);
  }
  to {
    transform: translate3d(1.5%, -1%, 0) scale(1.03);
  }
}

.shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2.5rem 1.1rem 3rem;
}

.card {
  width: min(420px, 100%);
  padding: 1.75rem 1.25rem 1.35rem;
  border-radius: 1.6rem;
  background: var(--card);
  border: 1px solid var(--card-border);
  box-shadow:
    0 18px 50px rgba(70, 130, 170, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(16px);
  text-align: center;
  animation: rise 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.section-block + .section-block {
  margin-top: 0.15rem;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.avatar-wrap {
  position: relative;
  width: 112px;
  height: 112px;
  margin: 0 auto 1rem;
  animation: avatar-float 5.5s cubic-bezier(0.45, 0.05, 0.55, 0.95) infinite;
  will-change: transform;
}

.avatar {
  width: 112px;
  height: 112px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  overflow: hidden;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.7rem;
  letter-spacing: 0.02em;
  color: #fff;
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.55), transparent 42%),
    linear-gradient(145deg, #8fd0ec, #5bb8e0 55%, #7ec8e8);
  border: 3px solid rgba(255, 255, 255, 0.95);
  box-shadow:
    0 0 0 4px rgba(91, 184, 224, 0.28),
    0 12px 28px rgba(70, 140, 180, 0.28);
  background-size: cover;
  background-position: center;
}

.avatar.has-image {
  font-size: 0;
  color: transparent;
}

@keyframes avatar-float {
  0% {
    transform: translate3d(0, 0, 0) rotate(0deg);
  }
  20% {
    transform: translate3d(1.5px, -6px, 0) rotate(-2deg);
  }
  40% {
    transform: translate3d(-1px, -11px, 0) rotate(1.4deg);
  }
  60% {
    transform: translate3d(1px, -7px, 0) rotate(-1.6deg);
  }
  80% {
    transform: translate3d(-1.5px, -3px, 0) rotate(1.2deg);
  }
  100% {
    transform: translate3d(0, 0, 0) rotate(0deg);
  }
}

.presence {
  position: absolute;
  right: 6px;
  bottom: 8px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #5ad68c;
  border: 3px solid #fff;
  box-shadow: 0 0 12px rgba(90, 214, 140, 0.45);
}

.presence[data-status="away"] {
  background: #f0c14a;
  box-shadow: 0 0 12px rgba(240, 193, 74, 0.4);
}

.presence[data-status="offline"] {
  background: #9aa6b2;
  box-shadow: none;
}

.presence[hidden] {
  display: none;
}

.name {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.75rem, 5vw, 2.05rem);
  letter-spacing: -0.01em;
  line-height: 1.1;
  color: #2a4256;
}

.handle {
  margin: 0.4rem 0 0;
  color: var(--accent);
  font-weight: 700;
  font-size: 0.98rem;
}

.bio {
  margin: 0.9rem auto 0;
  max-width: 34ch;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.5;
  min-height: 1.5em;
  font-weight: 600;
}

.bio .cursor {
  display: inline-block;
  width: 0.55ch;
  margin-left: 1px;
  background: var(--accent);
  animation: blink 1s steps(1) infinite;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

.socials {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1.15rem;
}

.social {
  width: 2.55rem;
  height: 2.55rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(91, 184, 224, 0.28);
  background: rgba(255, 255, 255, 0.72);
  color: #3d6f8c;
  padding: 0;
  cursor: pointer;
  font: inherit;
  box-shadow: 0 6px 16px rgba(80, 140, 180, 0.12);
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, color 160ms ease;
}

.social:hover {
  transform: translateY(-2px) scale(1.04);
  border-color: rgba(91, 184, 224, 0.55);
  background: #fff;
  color: var(--accent);
}

.social svg {
  width: 1.08rem;
  height: 1.08rem;
  fill: currentColor;
}

.links {
  display: grid;
  gap: 0.7rem;
  margin-top: 1.3rem;
}

.link {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.8rem;
  padding: 0.88rem 0.95rem;
  border-radius: 1.15rem;
  border: 1px solid rgba(91, 184, 224, 0.28);
  background: rgba(255, 255, 255, 0.7);
  text-align: left;
  box-shadow: 0 8px 20px rgba(80, 140, 180, 0.1);
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
  animation: rise 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.link:hover {
  transform: translateY(-2px);
  border-color: rgba(91, 184, 224, 0.5);
  background: #fff;
  box-shadow: 0 12px 28px rgba(80, 140, 180, 0.16);
}

.link.featured {
  border-color: rgba(232, 93, 93, 0.35);
  background:
    linear-gradient(120deg, rgba(91, 184, 224, 0.16), rgba(242, 160, 184, 0.14) 55%, rgba(255, 255, 255, 0.75));
}

.link-icon {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 0.85rem;
  display: grid;
  place-items: center;
  background: rgba(91, 184, 224, 0.14);
  border: 1px solid rgba(91, 184, 224, 0.2);
  color: #3d6f8c;
}

.link-icon svg {
  width: 1.15rem;
  height: 1.15rem;
  fill: currentColor;
  stroke: none;
}

.link-copy {
  min-width: 0;
}

.link-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.98rem;
  letter-spacing: -0.01em;
}

.link-sub {
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 0.12rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
}

.link-arrow {
  color: var(--muted);
  font-size: 1.15rem;
  transition: transform 160ms ease, color 160ms ease;
}

.link:hover .link-arrow {
  color: var(--accent);
  transform: translateX(3px);
}

.foot {
  margin: 1.25rem 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 700;
}

.foot .dot {
  margin: 0 0.35rem;
  opacity: 0.5;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  z-index: 20;
  transform: translateX(-50%) translateY(12px);
  padding: 0.65rem 1rem;
  border-radius: 999px;
  border: 1px solid rgba(91, 184, 224, 0.35);
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  font-size: 0.85rem;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 24px rgba(80, 140, 180, 0.18);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* Phones & small tablets */
@media (max-width: 640px) {
  .shell {
    padding: 1.25rem 0.85rem max(1.75rem, env(safe-area-inset-bottom));
    align-items: start;
    min-height: 100dvh;
  }

  .card {
    width: 100%;
    max-width: 100%;
    padding: 1.35rem 1rem 1.15rem;
    border-radius: 1.25rem;
  }

  .avatar {
    width: 5.5rem;
    height: 5.5rem;
  }

  .name {
    font-size: clamp(1.55rem, 7vw, 1.9rem);
  }

  .bio {
    font-size: 0.95rem;
  }

  .socials {
    gap: 0.55rem;
  }

  .social {
    min-width: 2.75rem;
    min-height: 2.75rem;
  }

  .links {
    gap: 0.55rem;
  }

  .link {
    min-height: 3rem;
    padding: 0.85rem 1rem;
    font-size: 0.98rem;
  }

  .toast {
    left: 0.75rem;
    right: 0.75rem;
    bottom: max(1rem, env(safe-area-inset-bottom));
    transform: translateY(12px);
    width: auto;
    text-align: center;
  }

  .toast.show {
    transform: translateY(0);
  }
}

/* Midnight fallback theme (selectable in Studio) */
body.theme-midnight {
  --bg: #07090d;
  --bg-deep: #05070b;
  --card: rgba(14, 18, 26, 0.78);
  --card-border: rgba(232, 240, 255, 0.1);
  --ink: #f4f7fc;
  --muted: rgba(198, 210, 228, 0.72);
  --accent: #7eb8c9;
  --accent-2: #c9a86a;
  color-scheme: dark;
}

body.theme-midnight .wash {
  background:
    radial-gradient(900px 500px at 50% -10%, rgba(126, 184, 201, 0.2), transparent 60%),
    radial-gradient(700px 480px at 85% 80%, rgba(201, 168, 106, 0.12), transparent 55%),
    linear-gradient(180deg, #0b1018 0%, #07090d 55%, #05070b 100%);
}

body.theme-midnight .clouds {
  opacity: 0.2;
}

body.theme-midnight .card,
body.theme-midnight .social,
body.theme-midnight .link {
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

body.theme-midnight .social,
body.theme-midnight .link {
  background: rgba(255, 255, 255, 0.03);
  color: var(--ink);
}

body.theme-midnight .name {
  color: var(--ink);
}

body.theme-midnight .toast {
  background: rgba(14, 18, 26, 0.92);
  color: var(--ink);
}
