/* The share sheet (share.js), on the map and the reading pages. Colours
   from tokens.css; each app's button in its own brand colour. Motion is
   off for anyone who asked their system for less. */

.sh {
  position: fixed;
  z-index: 4010; /* over the video player (reels.js, 4000) too */
  width: 368px;
  max-width: calc(100vw - 16px);
  padding: 14px 14px 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font);
  box-shadow: var(--shadow-float), 0 30px 60px -30px rgb(15 22 34 / 0.45);
  animation: sh-in 0.22s var(--spring, cubic-bezier(0.34, 1.4, 0.64, 1)) both;
}
.sh.is-closing { animation: sh-out 0.15s ease-in both; }

/* narrow screens: a sheet from the bottom, over a dimmed page */
.sh.sh-bottom {
  left: 0;
  right: 0;
  bottom: 0;
  width: auto;
  max-width: none;
  padding: 18px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  border-radius: 22px 22px 0 0;
  animation: sh-up 0.28s cubic-bezier(0.32, 0.72, 0, 1) both;
}
.sh.sh-bottom.is-closing { animation: sh-down 0.16s ease-in both; }
.sh.sh-bottom::before { content: ""; display: block; width: 38px; height: 4px; margin: -8px auto 12px; border-radius: 4px; background: var(--line); }
.sh-backdrop { position: fixed; inset: 0; z-index: 4009; background: rgb(8 12 20 / 0.42); animation: sh-fade 0.2s ease-out both; }
.sh-backdrop.is-closing { animation: sh-fade 0.16s ease-in reverse both; }

.sh-head { position: relative; padding-right: 34px; }
.sh-kicker { display: block; color: var(--ink-3); font-size: 11.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.sh-title { display: -webkit-box; margin-top: 2px; overflow: hidden; font-size: 15.5px; line-height: 1.3; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.sh-close {
  position: absolute;
  top: -4px;
  right: -4px;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--ink-2);
  cursor: pointer;
  transition: transform 0.18s, background 0.18s;
}
.sh-close:hover { background: var(--line); transform: rotate(90deg); }

.sh svg { width: 22px; height: 22px; fill: currentColor; }
.sh .sh-stroke { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sh-close .sh-stroke { width: 16px; height: 16px; }

/* the link and its copy button */
.sh-link {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0 14px;
  padding: 5px 5px 5px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
}
.sh-link-ic { display: grid; color: var(--ink-3); }
.sh-link-ic svg { width: 17px; height: 17px; }
.sh-url { flex: 1; min-width: 0; padding: 0; border: 0; background: none; color: var(--ink-2); font: 500 13px/1.2 var(--font); text-overflow: ellipsis; outline: none; }
.sh-copy {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 12px;
  border: 0;
  border-radius: 9px;
  background: var(--brand);
  color: #fff;
  font: 700 13px/1 var(--font);
  cursor: pointer;
  transition: background 0.2s, transform 0.12s;
}
.sh-copy:active { transform: scale(0.95); }
.sh-copy-ic { display: none; }
.sh-copy-ic svg { width: 15px; height: 15px; stroke-width: 2.6; }
.sh-copy.is-done { background: var(--good); animation: sh-pop 0.35s var(--spring, cubic-bezier(0.34, 1.4, 0.64, 1)); }
.sh-copy.is-done .sh-copy-ic { display: grid; }
.sh-copy.is-done .sh-copy-ic path { stroke-dasharray: 24; stroke-dashoffset: 24; animation: sh-tick 0.3s 0.05s ease-out forwards; }

/* the apps: round buttons in their colours, popping in one by one */
.sh-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 2px; }
.sh-app {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 6px 0 4px;
  border: 0;
  border-radius: 12px;
  background: none;
  color: var(--ink-2);
  font: inherit;
  text-decoration: none;
  cursor: pointer;
  animation: sh-item 0.32s calc(0.04s + var(--i) * 0.035s) var(--spring, cubic-bezier(0.34, 1.4, 0.64, 1)) both;
}
.sh-dot {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--brand-c);
  color: #fff;
  box-shadow: 0 6px 14px -8px var(--brand-c);
  transition: transform 0.18s var(--spring, cubic-bezier(0.34, 1.4, 0.64, 1)), box-shadow 0.18s;
}
.sh-name { font-size: 11px; font-weight: 600; white-space: nowrap; }
.sh-app:hover .sh-dot, .sh-app:focus-visible .sh-dot { transform: translateY(-3px) scale(1.06); box-shadow: 0 10px 18px -8px var(--brand-c); }
.sh-app:active .sh-dot { transform: scale(0.92); }
.sh-app:focus-visible { outline: 2px solid var(--focus); outline-offset: 0; }
.sh-app:hover .sh-name { color: var(--ink); }
.sh-bottom .sh-dot { width: 50px; height: 50px; }

/* a video's sheet: the link's apps, then the file's */
.sh-sub { margin: 10px 2px 2px; color: var(--ink-3); font-size: 11.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.sh-note { margin: 4px 2px 0; color: var(--ink-2); font-size: 13px; line-height: 1.35; }
.sh-note:empty { display: none; }

/* the share button that was tapped */
.sh-bounce svg, .sh-bounce .ic { animation: sh-bounce 0.42s var(--spring, cubic-bezier(0.34, 1.4, 0.64, 1)); }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .sh-app:is([data-app="x"], [data-app="tiktok"]) .sh-dot { background: #f2f5f9; color: #0b1118; }
}

@keyframes sh-in { from { opacity: 0; transform: scale(0.92) translateY(-4px); } }
@keyframes sh-out { to { opacity: 0; transform: scale(0.95); } }
@keyframes sh-up { from { transform: translateY(100%); } }
@keyframes sh-down { to { transform: translateY(100%); } }
@keyframes sh-fade { from { opacity: 0; } }
@keyframes sh-item { from { opacity: 0; transform: translateY(8px) scale(0.6); } }
@keyframes sh-pop { 40% { transform: scale(1.1); } }
@keyframes sh-tick { to { stroke-dashoffset: 0; } }
@keyframes sh-bounce { 30% { transform: translateY(-3px) rotate(-8deg) scale(1.15); } 60% { transform: translateY(0) rotate(4deg); } }

@media (prefers-reduced-motion: reduce) {
  .sh, .sh.sh-bottom, .sh.is-closing, .sh-backdrop, .sh-app, .sh-copy.is-done, .sh-bounce svg, .sh-bounce .ic { animation: none; }
  .sh-copy.is-done .sh-copy-ic path { animation: none; stroke-dashoffset: 0; }
  .sh-dot, .sh-close { transition: none; }
}
