/* =========================================================
   THEME VARIABLES
========================================================= */

:root {
  --bg: #e7e7e2;

  --panel: rgba(244, 244, 240, 0.82);
  --panel-hover: rgba(250, 250, 247, 0.96);

  --text: #252525;
  --muted: #777773;
  --link-text: rgba(30, 30, 30, 0.84);

  --border: rgba(35, 35, 35, 0.07);
  --card-border: rgba(30, 30, 30, 0.055);
  --card-border-hover: rgba(30, 30, 30, 0.11);

  --accent: #6574d9;
  --accent-soft: rgba(101, 116, 217, 0.12);

  --menu-bg: #f1f1ed;

  --shadow: 0 10px 30px rgba(40, 40, 40, 0.07);
  --menu-shadow: 0 14px 35px rgba(0, 0, 0, 0.14);

  /* Decorative atmosphere */
  --glow-top: rgba(120, 130, 190, 0.055);
  --glow-bottom: rgba(180, 170, 150, 0.05);
  --avatar-halo: rgba(101, 116, 217, 0.04);
  --card-sheen: rgba(101, 116, 217, 0.035);
  --noise-opacity: 0.018;
}

html[data-theme="dark"] {
  --bg: #1b1c1e;

  --panel: rgba(255, 255, 255, 0.055);
  --panel-hover: rgba(255, 255, 255, 0.085);

  --text: #e7e7e3;
  --muted: #a0a09a;
  --link-text: rgba(238, 238, 234, 0.9);

  --border: rgba(255, 255, 255, 0.075);
  --card-border: rgba(255, 255, 255, 0.055);
  --card-border-hover: rgba(255, 255, 255, 0.11);

  --accent: #8290e8;
  --accent-soft: rgba(130, 144, 232, 0.13);

  --menu-bg: #292a2d;

  --shadow: 0 12px 34px rgba(0, 0, 0, 0.2);
  --menu-shadow: 0 14px 35px rgba(0, 0, 0, 0.28);

  /* Decorative atmosphere */
  --glow-top: rgba(120, 132, 220, 0.07);
  --glow-bottom: rgba(80, 90, 150, 0.035);
  --avatar-halo: rgba(130, 144, 232, 0.055);
  --card-sheen: rgba(130, 144, 232, 0.035);
}


/* =========================================================
   RESET / BASE
========================================================= */

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

html {
  min-height: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;

  position: relative;
  isolation: isolate;

  background:
    radial-gradient(
      circle at 50% -5%,
      var(--glow-top),
      transparent 32%
    ),
    radial-gradient(
      circle at 50% 100%,
      var(--glow-bottom),
      transparent 38%
    ),
    var(--bg);

  color: var(--text);

  font-family:
    Inter,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;

  transition:
    background-color 0.3s ease,
    color 0.3s ease;
}

/* Subtle texture above the background, below all content */
body::before {
  content: "";

  position: fixed;
  inset: 0;
  z-index: 0;

  pointer-events: none;

  opacity: var(--noise-opacity);

  background-image:
    url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.7'/%3E%3C/svg%3E");
}

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

button {
  font: inherit;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}


/* =========================================================
   PAGE
========================================================= */

.page {
  position: relative;
  z-index: 1;

  width: min(calc(100% - 30px), 560px);
  margin: 0 auto;
  padding: 28px 0 44px;
}


/* =========================================================
   TOP BAR
========================================================= */

.topbar {
  width: calc(100% - 24px);

  display: flex;
  align-items: center;
  justify-content: space-between;

  margin: 0 auto 24px;

  opacity: 0;
  transform: translateY(-8px);

  animation: enter 0.55s ease forwards;
}

.icon-button {
  width: 40px;
  height: 40px;

  display: grid;
  place-items: center;

  padding: 0;

  border: 1px solid var(--border);
  border-radius: 14px;

  background: var(--panel);

  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);

  cursor: pointer;

  transition:
    transform 0.2s ease,
    background 0.2s ease,
    border-color 0.2s ease;
}

.icon-button:hover {
  background: var(--panel-hover);
  transform: translateY(-2px);
}

.icon-button:active {
  transform: scale(0.96);
}

.icon-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.icon-button svg {
  width: 18px;
  height: 18px;

  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}


/* =========================================================
   PROFILE
========================================================= */

.profile {
  margin-bottom: 28px;

  text-align: center;

  opacity: 0;
  transform: translateY(10px);

  animation: enter 0.6s 0.08s ease forwards;
}

.avatar {
  width: 88px;
  height: 88px;

  display: block;
  margin: 0 auto 18px;

  object-fit: cover;

  border: 1px solid var(--card-border);
  border-radius: 50%;

  box-shadow:
    0 0 0 5px var(--avatar-halo),
    var(--shadow);
}

.profile h1 {
  margin: 0;

  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.025em;
}

.tags {
  margin: 10px 0 0;

  color: var(--muted);
  font-size: 12px;
}

.tags span {
  margin: 0 6px;
  color: var(--accent);
}

.bio {
  margin: 8px 0 0;

  color: var(--text);
  opacity: 0.82;
  font-size: 12px;
}

.bio-sub {
  margin: 4px 0 0;

  color: var(--muted);
  font-size: 11px;
}

.profile-divider {
  width: 400px;
  height: 1px;

  margin: 20px auto 0;

  border-radius: 999px;

  background:
    linear-gradient(
      90deg,
      transparent 0%,
      var(--accent) 30%,
      var(--accent) 70%,
      transparent 100%
    );

  opacity: 0.65;

  box-shadow:
    0 0 10px
    var(--accent-soft);
}


/* =========================================================
   LINKS
========================================================= */

.links {
  display: grid;
  gap: 10px;
}

.link-card {
  position: relative;
  z-index: 1;

  min-height: 68px;

  display: grid;
  grid-template-columns: 52px 1fr 52px;
  align-items: center;

  padding: 0 12px;

  overflow: visible;

  border: 1px solid var(--card-border);
  border-radius: 8px;

  background: var(--panel);

  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);

  cursor: pointer;

  opacity: 0;
  transform: translateY(12px);

  animation: enter 0.5s ease forwards;

  transition:
    background 0.2s ease,
    border-color 0.2s ease,
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

/* Subtle card sheen */
.link-card::after {
  content: "";

  position: absolute;
  inset: 0;

  border-radius: inherit;

  pointer-events: none;

  opacity: 0;

  background:
    linear-gradient(
      90deg,
      transparent,
      var(--card-sheen),
      transparent
    );

  transition: opacity 0.2s ease;
}

/* Keep an opened menu above neighboring cards */
.link-card:has(.link-menu.open) {
  z-index: 100;
}

/* Staggered entrance */
.link-card:nth-child(1) { animation-delay: 0.12s; }
.link-card:nth-child(2) { animation-delay: 0.16s; }
.link-card:nth-child(3) { animation-delay: 0.20s; }
.link-card:nth-child(4) { animation-delay: 0.24s; }
.link-card:nth-child(5) { animation-delay: 0.28s; }
.link-card:nth-child(6) { animation-delay: 0.32s; }
.link-card:nth-child(7) { animation-delay: 0.36s; }
.link-card:nth-child(8) { animation-delay: 0.40s; }
.link-card:nth-child(9) { animation-delay: 0.44s; }

.link-card:active {
  transform: scale(0.992);
}

.link-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}


/* =========================================================
   LINK LOGO
========================================================= */

.link-logo {
  width: 34px;
  height: 34px;

  justify-self: start;

  object-fit: contain;
  object-position: center;

  border-radius: 6px;

  transition: transform 0.2s ease;
}

.link-logo-avatar {
  object-fit: cover;
  border-radius: 50%;
}


/* =========================================================
   LINK TITLE
========================================================= */

.link-title {
  justify-self: center;

  text-align: center;

  color: var(--link-text);

  font-size: 14px;
  font-weight: 520;
  letter-spacing: -0.005em;

  pointer-events: none;
}


/* =========================================================
   THREE-DOT ACTION BUTTON
========================================================= */

.link-actions {
  position: relative;
  z-index: 2;

  justify-self: end;
}

.link-more {
  width: 32px;
  height: 32px;

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;

  padding: 0;

  border: 0;
  border-radius: 8px;

  background: transparent;

  cursor: pointer;

  transition:
    background 0.2s ease,
    transform 0.2s ease;
}

.link-more:hover {
  background: var(--accent-soft);
}

.link-more:active {
  transform: scale(0.92);
}

.link-more:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.link-more span {
  width: 3px;
  height: 3px;

  display: block;
  margin: 1.5px 0;

  border-radius: 50%;

  background: var(--muted);
}


/* =========================================================
   LINK MENU
========================================================= */

.link-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 200;

  min-width: 145px;

  padding: 6px;

  border: 1px solid var(--border);
  border-radius: 10px;

  background: var(--menu-bg);

  box-shadow: var(--menu-shadow);

  opacity: 0;
  visibility: hidden;

  transform: translateY(6px);

  transition:
    opacity 0.18s ease,
    transform 0.18s ease,
    visibility 0.18s ease;
}

.link-menu.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.link-menu button {
  width: 100%;

  padding: 10px 11px;

  border: 0;
  border-radius: 8px;

  background: transparent;

  color: var(--text);

  text-align: left;
  white-space: nowrap;

  font-size: 12px;

  cursor: pointer;

  transition: background 0.15s ease;
}

.link-menu button:hover {
  background: var(--accent-soft);
}

.link-menu button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* Open the last two menus upward */
.link-card:nth-last-child(-n + 2) .link-menu {
  top: auto;
  bottom: calc(100% + 8px);
  transform: translateY(-6px);
}

.link-card:nth-last-child(-n + 2) .link-menu.open {
  transform: translateY(0);
}


/* =========================================================
   FOOTER
========================================================= */

.footer {
  display: flex;
  align-items: center;
  justify-content: center;

  gap: 6px;

  margin-top: 28px;

  color: var(--muted);
  font-size: 10px;
}

.footer-sep {
  opacity: 0.7;
}


/* =========================================================
   TOAST
========================================================= */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 500;

  padding: 10px 14px;

  border: 1px solid var(--border);
  border-radius: 999px;

  background: var(--panel-hover);

  color: var(--text);

  box-shadow: var(--shadow);

  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);

  font-size: 11px;

  opacity: 0;
  pointer-events: none;

  transform: translate(-50%, 12px);

  transition:
    opacity 0.25s ease,
    transform 0.25s ease;
}

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


/* =========================================================
   DESKTOP / POINTER HOVER
========================================================= */

@media (hover: hover) {
  .link-card:hover {
    background: var(--panel-hover);
    border-color: var(--card-border-hover);

    transform: translateY(-1px);

    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  }

  .link-card:hover::after {
    opacity: 1;
  }

  .link-card:hover .link-logo {
    transform: scale(1.06) rotate(-1deg);
  }
}


/* =========================================================
   ANIMATION
========================================================= */

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


/* =========================================================
   MOBILE
========================================================= */

@media (max-width: 480px) {
  .page {
    width: calc(100% - 24px);
    padding: 18px 0 34px;
  }

  .topbar {
    width: calc(100% - 8px);
    margin: 0 auto 22px;
  }

  .profile {
    margin-bottom: 26px;
  }

  .avatar {
    width: 80px;
    height: 80px;
  }

  .link-card {
    min-height: 66px;
    grid-template-columns: 50px 1fr 54px;
    padding: 0 10px;
  }

  .link-card:active {
    background: var(--panel-hover);
    transform: scale(0.985);
  }

  .link-logo {
    width: 32px;
    height: 32px;
  }

  .link-title {
    font-size: 14px;
  }

  .icon-button:active {
    transform: scale(0.92);
  }

  /* 44x44 gives a comfortable touch target */
  .link-more {
    width: 44px;
    height: 44px;
    border-radius: 10px;
  }

  .link-more span {
    width: 4px;
    height: 4px;
    margin: 2px 0;
  }

  .link-menu {
    top: calc(100% + 10px);
    right: -2px;

    min-width: 180px;

    padding: 8px;
    border-radius: 14px;
  }

  .link-menu button {
    min-height: 48px;

    display: flex;
    align-items: center;

    padding: 0 14px;

    border-radius: 9px;

    font-size: 14px;
    font-weight: 500;
  }

  .link-card:nth-last-child(-n + 2) .link-menu {
    top: auto;
    bottom: calc(100% + 10px);
  }

  .profile-divider {
    width: 54px;
    margin-top: 18px;
  }
}


/* =========================================================
   SMALL MOBILE
========================================================= */

@media (max-width: 360px) {
  .page {
    width: calc(100% - 16px);
  }

  .link-card {
    grid-template-columns: 46px 1fr 50px;
    padding: 0 8px;
  }

  .link-logo {
    width: 30px;
    height: 30px;
  }

  .link-menu {
    min-width: 168px;
  }
}


/* =========================================================
   ACCESSIBILITY
========================================================= */

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