/* =========================================================================
   Social icons and the social bar (js/social-dock.js).

   The bar sticks to the bottom of the screen. On the first screen it sits
   on a soft fade, like the bottom of the page; scrolling down slides it
   away, scrolling up brings it back on a frosted capsule; at the end of
   the page it rests in the footer. The script sets two values on the bar:
     --fade  1 = soft fade behind the icons (top of the page)
     --bar   1 = frosted capsule behind the icons (after scrolling up)
   Both are 0 when it rests in the footer.
   ========================================================================= */

/* ---------- Icons ---------- */

.socials {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.socials li {
  display: block;
}

/* Each icon is a fixed-size link that never moves or resizes, so the
   pointer can't slip on and off it. The circle is a separate layer
   (::before) that ignores the pointer; only it and the icon animate. */
.socials a {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  color: #fff;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.socials a::before {
  content: "";
  position: absolute;
  inset: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--card);
  box-shadow: 0 14px 14px -8px rgba(0, 0, 0, 0.7), 0 1px 10px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  transition: transform 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
}

.socials svg {
  position: relative; /* above the circle */
  width: 20px;
  height: 20px;
  fill: currentColor;
  pointer-events: none;
  transition: color 0.2s ease;
}

.socials svg.ra-icon {
  width: 24px;
  height: 12px;
}

.socials a:hover,
.socials a:focus-visible {
  color: #0b0b0b;
}

.socials a:hover::before,
.socials a:focus-visible::before {
  border-color: var(--text);
  background: var(--text);
  transform: scale(1.08);
}

/* ---------- Bar ---------- */

/* where the bar rests: one section gap below the last card */
.social-dock-mark {
  height: 0;
  margin-top: calc(var(--section-gap) - 24px);
}

.social-dock {
  --bar: 0;
  --fade: 1;
  position: sticky;
  bottom: 0;
  z-index: 40;
  padding: 24px 0 calc(24px + env(safe-area-inset-bottom, 0px));
  will-change: transform;
}

/* sliding in and out; otherwise the bar follows scrolling exactly */
.social-dock.is-sliding {
  transition: transform 0.7s cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* soft fade into the page behind the icons (first screen) */
.social-dock::after {
  content: "";
  position: absolute;
  z-index: -1;
  top: -60px;
  bottom: 0;
  left: calc(50% - 50vw);
  width: 100vw;
  background: linear-gradient(to top, #0b0b0b, rgba(11, 11, 11, 0.96) 62%, rgba(11, 11, 11, 0));
  opacity: var(--fade);
  transition: opacity 0.6s ease;
  pointer-events: none;
}

/* The icon row is as wide as the header buttons (500px at most). Without
   the capsule the first and last icons line up with the button edges;
   with it they ease inward to sit inside its rounded ends. */
.social-dock .socials {
  --edge: 0px; /* inset from the button edges when there's no capsule */
  --inset: 26px; /* extra inset when the capsule shows */
  position: relative;
  isolation: isolate;
  max-width: 500px;
  margin: 0 auto;
  padding: 0 calc(var(--edge) + var(--inset) * var(--bar));
  justify-content: space-between;
  transition: padding 0.6s ease;
}

/* Frosted capsule: a light tint over a dark base, a fine highlight on the
   edge and a soft shadow. No live blur: blurring the page behind it made
   Chrome redraw the cards underneath while scrolling, which flickered. */
.social-dock .socials::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: -16px 0;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.04)),
    rgba(20, 20, 20, 0.72);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 14px 34px rgba(0, 0, 0, 0.5);
  opacity: var(--bar);
  transition: opacity 0.6s ease;
  pointer-events: none;
}

/* the icons' own shadows fade out while the capsule shows */
.social-dock .socials a::before {
  box-shadow: 0 14px 14px -8px rgba(0, 0, 0, calc(0.7 * (1 - var(--bar)))),
    0 1px 10px rgba(0, 0, 0, calc(0.35 * (1 - var(--bar))));
  transition: transform 0.2s ease, background-color 0.2s ease, border-color 0.2s ease,
    box-shadow 0.6s ease;
}

/* ---------- Phones ---------- */

@media (max-width: 560px) {
  .socials {
    gap: 10px;
  }

  .socials a {
    width: 40px;
    height: 40px;
  }

  .socials svg {
    width: 18px;
    height: 18px;
  }

  .social-dock {
    padding-top: 20px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  }

  .social-dock-mark {
    margin-top: calc(var(--section-gap) - 20px);
  }

  /* the icons spread evenly across the row, 16px in from the screen-wide
     button edges so they don't hug the screen; never wrap */
  .social-dock .socials {
    --edge: 16px;
    --inset: 12px;
    gap: 0;
    flex-wrap: nowrap;
  }

  .social-dock .socials::before {
    inset: -12px 0;
  }
}

/* narrow phones: smaller icons and a little less inset, so all six fit
   on one line with room between them */
@media (max-width: 374px) {
  .socials {
    gap: 6px;
  }

  .socials a {
    width: 34px;
    height: 34px;
  }

  .social-dock .socials {
    --edge: 12px;
    --inset: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .social-dock.is-sliding {
    transition: none;
  }
}
