#socials-dock {
  position: relative;
  width: 100%;
  padding: 4em 0;
  display: flex;
  flex-direction: column;
  gap: 2em;

  .title-container {
    margin: 0 4em 3em 4em;
  }

  .text-container {
    margin: 0 auto 3em auto;
  }

  h3 {
    font-size: clamp(1em, 10vw, 3em);
    font-weight: 300;
    margin: 0 auto;
    text-align: center;
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.25em;
    transition: gap 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: default;
  }

  h3 iconify-icon {
    opacity: 0;
    transform: translateX(-10px);
    transition: opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1),
      transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    flex-shrink: 0;
    margin-left: 0;
    max-width: 0;
    overflow: hidden;
    transition: opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1),
      transform 0.35s cubic-bezier(0.4, 0, 0.2, 1),
      max-width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  }

  h3:hover {
    gap: 0.5em;
  }

  h3:hover iconify-icon,
  h3:focus-visible iconify-icon {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
    max-width: 2.625em;
  }

  /* Add subtle text color change on hover for better UX */
  h3:hover {
    color: var(--foreground);
    filter: brightness(1.1);
  }

  /* Ensure smooth transition back */
  h3:not(:hover) iconify-icon {
    transition-delay: 0s, 0s, 0.1s; /* Delay width collapse slightly */
  }
}

#socials-content {
  width: 100%;
  max-width: max-content;
  margin: 0 auto;
  border-bottom: solid;
  padding: 2em 4em;
  overflow: visible;
}

#socials-display {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.75em;
  padding: 1.5em 2em;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(20px);
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  position: relative;
  overflow: visible;

  /* Mac dock styling */
  &::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.15) 0%,
      rgba(255, 255, 255, 0.05) 100%
    );
    border-radius: inherit;
    pointer-events: none;
  }

  a {
    position: relative;
    width: 4.5em; /* 72px/16 = 4.5em */
    height: 4.5em;
    border: 2px solid rgba(255, 255, 255, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    transform-origin: bottom center;
    z-index: 1;
    overflow: visible;

    &:focus-visible {
      outline: 3px solid var(--accent-color, #007aff);
      outline-offset: 3px;
      border-color: var(--accent-color, #007aff);
    }

    /* Mac dock hover effect */
    &:hover {
      transform: translateY(-12px) scale(1.4);
      border-color: rgba(255, 255, 255, 0.6);
      background: rgba(255, 255, 255, 0.2);
      box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15),
        0 10px 20px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.3);
      z-index: 10;
    }

    /* Magnetic effect for adjacent icons */
    &:hover + a,
    &:has(+ a:hover) {
      transform: translateY(-6px) scale(1.15);
    }

    &:hover + a + a,
    &:has(+ a + a:hover) {
      transform: translateY(-3px) scale(1.05);
    }

    /* Two icons away effect */
    &:nth-child(1):hover ~ a:nth-child(4),
    &:nth-child(2):hover ~ a:nth-child(5),
    &:nth-child(3):hover ~ a:nth-child(6),
    &:nth-child(4):hover ~ a:nth-child(7) {
      transform: translateY(-2px) scale(1.02);
    }
  }

  iconify-icon {
    width: 2.5em; /* 40px/16 = 2.5em */
    height: 2.5em;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
  }

  a:hover iconify-icon {
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
  }
}

#socials-display a .tooltip {
  position: absolute;
  bottom: calc(100% + 1em);
  left: 50%;
  transform: translateX(-50%) translateY(10px) scale(0.8);
  background: var(--foreground);
  color: var(--background);
  padding: 0.6em 1.2em;
  border-radius: 16px;
  font-size: 0.85em;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  z-index: 20;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  backdrop-filter: blur(10px);

  &::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 8px solid transparent;
    border-top-color: var(--foreground);
  }
}

#socials-display a:hover .tooltip,
#socials-display a:focus-visible .tooltip {
  opacity: 1;
  transform: translateX(-50%) translateY(0) scale(1);
  transition-delay: 0.2s;
}

/* Responsive Design */
@media (min-width: 901px) {
  #socials-dock{
    .text-container {
      &.mobile{
        display: none;
      }
    }
  }
}
@media (max-width: 900px) {
  #socials-dock {
    padding: 2em 0;

    .title-container {
      margin: 0 2em 2em 2em;
    }

    .text-container {
      margin: 0 2em 2em 2em;
      &.desktop{
        display: none;
      }
      &.mobile {
        font-size: clamp(2em, 10vw, 1em);
      }
    }
  }

  #socials-content {
    padding: 1.5em 2em;
  }

  #socials-display {
    gap: 0.5em;
    padding: 1.25em 1.5em;
    border-radius: 20px;

    a {
      width: 3.75em; /* 60px/16 = 3.75em */
      height: 3.75em;
      border-radius: 16px;

      &:hover {
        transform: translateY(-10px) scale(1.3);
      }

      &:hover + a,
      &:has(+ a:hover) {
        transform: translateY(-5px) scale(1.1);
      }

      &:hover + a + a,
      &:has(+ a + a:hover) {
        transform: translateY(-2px) scale(1.03);
      }
    }

    iconify-icon {
      width: 2.25em; /* 36px/16 = 2.25em */
      height: 2.25em;
    }
  }
}

@media (max-width: 600px) {
  #socials-dock {
    padding: 2em 1em;

    .title-container {
      margin: 0 0 1.5em 0;
    }

    .text-container {
      margin: 0 0 1.5em 0;

      &.desktop {
        display: none;
      }
    }

    h3 {
      font-size: clamp(1em, 8vw, 2.5em);
    }

    h3 iconify-icon {
      width: 1.75em; /* 28px/16 = 1.75em */
      height: 1.75em;
    }

    h3:hover iconify-icon,
    h3:focus-visible iconify-icon {
      max-width: 1.75em;
    }
  }

  #socials-content {
    padding: 1em;
  }

  #socials-display {
    gap: 0.4em;
    padding: 1em 1.25em;
    border-radius: 18px;

    a {
      width: 3.25em; /* 52px/16 = 3.25em */
      height: 3.25em;
      border-radius: 14px;

      &:hover {
        transform: translateY(-8px) scale(1.25);
      }

      &:hover + a,
      &:has(+ a:hover) {
        transform: translateY(-4px) scale(1.08);
      }

      &:hover + a + a,
      &:has(+ a + a:hover) {
        transform: translateY(-2px) scale(1.02);
      }
    }

    iconify-icon {
      width: 1.875em; /* 30px/16 = 1.875em */
      height: 1.875em;
    }
  }

  #socials-display a .tooltip {
    font-size: 0.8em;
    padding: 0.5em 1em;
    border-radius: 12px;
    bottom: calc(100% + 0.75em);

    &::after {
      border-width: 6px;
    }
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  #socials-display {
    border-color: currentColor;

    a {
      border-color: currentColor;
      background: transparent;

      &:hover {
        background: currentColor;
        color: var(--background);
      }
    }
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  #socials-display a {
    transition: transform 0.2s ease, background-color 0.2s ease;

    &:hover {
      transform: scale(1.1);
    }

    &:hover + a,
    &:has(+ a:hover),
    &:hover + a + a,
    &:has(+ a + a:hover) {
      transform: none;
    }
  }

  #socials-display a .tooltip {
    transition: opacity 0.2s ease;
    transform: translateX(-50%);

    &:hover {
      transform: translateX(-50%);
    }
  }
}

/* Dark mode optimizations */
@media (prefers-color-scheme: dark) {
  #socials-display {
    background: rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 255, 255, 0.1);

    &::before {
      background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.1) 0%,
        rgba(255, 255, 255, 0.02) 100%
      );
    }

    a {
      background: rgba(0, 0, 0, 0.2);
      border-color: rgba(255, 255, 255, 0.2);

      &:hover {
        background: rgba(255, 255, 255, 0.1);
        border-color: rgba(255, 255, 255, 0.4);
      }
    }
  }
}
