/**
 * Compact anchored share card (desktop) and content-height bottom sheet (phone / touch-only tablet).
 * Trigger stays in-page; the panel is shown in the top layer (Popover API) or a document host.
 */

.share-menu {
  position: relative;
  display: inline-flex;
  vertical-align: middle;
}

.share-menu__trigger--button,
.share-menu__trigger--text {
  min-height: 44px;
  min-width: 44px;
}

/* Lightweight icon + “Share” label (collection heroes). */
.share-menu__trigger--icon-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  min-width: 44px;
  margin: 0;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.01em;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.share-menu__trigger--icon-label svg {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.share-menu__trigger-label {
  flex: 0 0 auto;
  white-space: nowrap;
}

/* Polished hover/focus tip for icon-only share triggers (readers, etc.). */
.share-menu__trigger[data-share-tooltip] {
  position: relative;
}

.share-menu__tooltip {
  position: absolute;
  left: 50%;
  top: calc(100% + 8px);
  z-index: 50;
  display: block;
  padding: 0.4rem 0.65rem;
  border-radius: 8px;
  background: rgba(4, 30, 66, 0.96);
  color: #ffffff;
  font-family: var(--font, inherit);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.02em;
  white-space: nowrap;
  box-shadow: 0 8px 20px rgba(4, 30, 66, 0.22);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transform: translateX(-50%) translateY(-3px);
  transition: opacity 0.14s ease, transform 0.14s ease, visibility 0.14s ease;
}

.share-menu__tooltip::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 100%;
  width: 0;
  height: 0;
  margin-left: -5px;
  border: 5px solid transparent;
  border-bottom-color: rgba(4, 30, 66, 0.96);
}

.share-menu__trigger[data-share-tooltip]:hover:not([aria-expanded="true"]) .share-menu__tooltip,
.share-menu__trigger[data-share-tooltip]:focus-visible:not([aria-expanded="true"]) .share-menu__tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

@media (hover: none) {
  .share-menu__trigger[data-share-tooltip]:hover:not(:focus-visible) .share-menu__tooltip {
    opacity: 0;
    visibility: hidden;
  }
}

@media (prefers-reduced-motion: reduce) {
  .share-menu__tooltip {
    transition: none;
  }
}

.share-menu__panel[hidden] {
  display: none !important;
}

/* Desktop / laptop floating card — never full-width, never backdrop. */
.share-menu__panel[popover] {
  position: fixed;
  inset: unset;
  margin: 0;
  padding: 0;
  border: 0;
  overflow: visible;
  background: transparent;
  color: inherit;
  width: 340px;
  max-width: calc(100vw - 32px);
  height: fit-content;
  min-height: 0;
  box-sizing: border-box;
}

.share-menu__panel[popover]:not(:popover-open) {
  display: none !important;
}

.share-menu__panel.is-fallback {
  position: fixed;
  z-index: 6000;
  width: 340px;
  max-width: calc(100vw - 32px);
  height: fit-content;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  box-sizing: border-box;
}

.share-menu__scrim {
  display: none;
}

.share-menu__surface {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  width: 100%;
  min-height: 0;
  padding: 0.75rem 0.75rem 0.8rem;
  border: 1px solid var(--ps-border, #d8e0ea);
  border-radius: var(--radius, 12px);
  background: var(--ps-surface, #ffffff);
  box-shadow: 0 12px 28px rgba(4, 30, 66, 0.18);
  box-sizing: border-box;
  color: var(--ps-navy, #041e42);
}

.share-menu__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  min-height: 0;
}

.share-menu__title {
  margin: 0;
  min-width: 0;
  font-family: var(--font, inherit);
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--ps-navy, #041e42);
}

.share-menu__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ps-navy, #041e42);
  font: inherit;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}

.share-menu__close:hover,
.share-menu__close:focus-visible {
  background: rgba(4, 30, 66, 0.06);
}

.share-menu__close:focus-visible {
  outline: 2px solid var(--ps-accent, #a50034);
  outline-offset: 2px;
}

.share-menu__live {
  margin: 0;
}

.share-menu__copy {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px;
  width: 100%;
  margin: 0;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--ps-navy, #041e42);
  border-radius: 8px;
  background: var(--ps-navy, #041e42);
  color: #ffffff;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  box-sizing: border-box;
}

.share-menu__copy:hover,
.share-menu__copy:focus-visible {
  background: var(--ps-accent-dark, #003d58);
  border-color: var(--ps-accent-dark, #003d58);
  color: #ffffff;
}

.share-menu__copy:focus-visible,
.share-menu__grid-item:focus-visible {
  outline: 2px solid var(--ps-accent, #a50034);
  outline-offset: 2px;
}

.share-menu__copy.is-copied {
  background: var(--ps-accent-dark, #004f71);
  border-color: var(--ps-accent-dark, #004f71);
}

.share-menu__copy-icon,
.share-menu__grid-icon {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.share-menu__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.3rem;
}

.share-menu__grid-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.28rem;
  min-height: 44px;
  min-width: 44px;
  margin: 0;
  padding: 0.5rem 0.2rem 0.4rem;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ps-navy, #041e42);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.15;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  box-sizing: border-box;
}

.share-menu__grid-item:hover,
.share-menu__grid-item:focus-visible {
  background: rgba(4, 30, 66, 0.06);
  color: var(--ps-navy, #041e42);
}

.share-menu__grid-item span {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Mobile / touch-only: full-viewport scrim, content-height sheet surface. */
.share-menu__panel.is-sheet[popover],
.share-menu__panel.is-sheet.is-fallback {
  inset: 0;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  max-width: none;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  background: transparent;
}

.share-menu__panel.is-sheet .share-menu__scrim {
  display: block;
  position: absolute;
  inset: 0;
  border: 0;
  margin: 0;
  padding: 0;
  background: rgba(4, 30, 66, 0.4);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.22s ease;
}

.share-menu__panel.is-sheet.is-visible .share-menu__scrim {
  opacity: 1;
}

.share-menu__panel.is-sheet .share-menu__surface {
  position: relative;
  z-index: 1;
  width: 100%;
  height: auto;
  min-height: 0;
  max-height: min(80dvh, calc(100dvh - env(safe-area-inset-top, 0px) - 12px));
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 0.9rem 1rem calc(0.9rem + env(safe-area-inset-bottom, 0px));
  border: 0;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -8px 32px rgba(4, 30, 66, 0.18);
  transform: translateY(100%);
  transition: transform 0.22s ease;
}

.share-menu__panel.is-sheet.is-visible .share-menu__surface {
  transform: translateY(0);
}

.share-menu__panel.is-sheet .share-menu__close {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
}

.share-menu__panel.is-sheet .share-menu__title {
  font-size: 1rem;
}

body.share-sheet-open {
  overflow: hidden;
}

/* Collection hero: icon+label sits in the top utility row with the back link. */
.collection-hero-utility {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  margin: 0 0 0.85rem;
  min-height: 44px;
}

.collection-hero-utility .collection-hero-back,
.collection-hero-utility .collection-back-link {
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
}

.collection-hero-utility .share-menu {
  flex: 0 0 auto;
  margin: 0;
}

.collection-hero .collection-hero-share-trigger.share-menu__trigger--icon-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: auto;
  height: auto;
  min-width: 44px;
  min-height: 44px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #ffffff;
  box-shadow: none;
  cursor: pointer;
}

.collection-hero .collection-hero-share-trigger.share-menu__trigger--icon-label svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.collection-hero .collection-hero-share-trigger.share-menu__trigger--icon-label:hover,
.collection-hero .collection-hero-share-trigger.share-menu__trigger--icon-label:focus-visible {
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
}

.collection-hero .collection-hero-share-trigger.share-menu__trigger--icon-label:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.95);
  outline-offset: 2px;
}

.collection-hero .collection-hero-share-trigger.share-menu__trigger--icon-label[aria-expanded="true"] {
  background: rgba(255, 255, 255, 0.18);
}

@media (max-width: 767px) {
  .collection-hero-utility {
    gap: 0.5rem;
  }
}

@media (max-width: 360px) {
  .share-menu__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  .share-menu__panel,
  .share-menu__surface,
  .share-menu__scrim {
    transition: none !important;
    animation: none !important;
  }
}
