/* The share sheet (js/share.js). On a phone it rises from the bottom edge; on a wider screen it
   is a small dialog. It uses the colour variables from style.css and the .help, .btn, .icon-btn,
   .note and .link classes defined there. */

.help.share-sheet {
  inset-inline: 0;
  width: 100%;
  max-width: 100%;
  max-height: calc(100svh - 12px);
  margin: auto 0 0;
  padding: 0;
  border-radius: 22px 22px 0 0;
  overflow: auto;
  overscroll-behavior: contain;
}
.share-wrap { display: grid; gap: 12px; min-width: 0; padding: 14px 16px 0; }
.share-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.help .share-head h2 { margin: 0; font-size: 1.3rem; }
.share-close { flex: none; display: grid; place-items: center; }

/* The card or a video: real radio buttons, shown as a row of keys. A round has two (Score card,
   Replay); a series has three (Recap card and its two videos). Every key in the row is as tall as
   the tallest, so a name that wraps doesn't leave the others' faces short. */
.share-seg { min-width: 0; margin: 0; padding: 0; border: 0; }
.share-seg-row { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; border-radius: 16px; background: var(--paper); }
.help label.share-seg-opt { position: relative; display: grid; min-width: 0; font-size: 1rem; cursor: pointer; }
.help label.share-seg-opt[hidden] { display: none; }
.share-seg-opt input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.share-seg-face {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 4px 2px;
  border-radius: 12px;
  color: var(--muted);
  text-align: center;
  line-height: 1.15;
}
.share-seg-face b { font-size: 1rem; font-weight: 800; }
.share-seg-face small { font-size: 0.75rem; font-weight: 400; }
/* Three keys share a phone's width: a little smaller, so each name fits its third on one line. */
.share-seg-row[data-count="3"] .share-seg-face { padding-inline: 1px; }
.share-seg-row[data-count="3"] .share-seg-face b { font-size: 0.9rem; }
.share-seg-row[data-count="3"] .share-seg-face small { font-size: 0.7rem; }
.share-seg-opt input:checked + .share-seg-face { background: var(--primary); color: var(--primary-ink); }
.share-seg-opt input:focus-visible + .share-seg-face { outline: 3px solid var(--ink); outline-offset: 1px; }

/* The preview: the card as it will look, or the replay. Its box has the picture's shape before
   the picture exists, so the sheet does not jump when it arrives. */
.share-preview { display: grid; place-items: center; padding: 12px; border-radius: 18px; background: var(--bg); }
.share-shot, .share-clip-box { display: block; max-width: 100%; border-radius: 12px; }
.share-shot { background: var(--paper); box-shadow: var(--shadow); }
.share-preview[data-format="square"] :is(.share-shot, .share-clip-box) { width: min(100%, 300px, 36svh); aspect-ratio: 1; }
.share-preview[data-format="vertical"] :is(.share-shot, .share-clip-box) { width: auto; height: min(38svh, 400px); aspect-ratio: 9 / 16; }
.share-clip-box:not([hidden]) {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 12px;
  padding: 16px;
  border: 2px dashed var(--grid);
  text-align: center;
}
/* Square or Tall, under the preview: the same keys, smaller, each with a little picture of its shape. */
.share-shape .share-seg-face { flex-direction: row; gap: 10px; min-height: 44px; text-align: left; }
.share-shape .share-seg-face span { display: grid; min-width: 0; }
.share-shape .share-seg-face b { font-size: 0.92rem; }
.share-ratio { flex: none; box-sizing: border-box; width: 16px; height: 16px; border: 2.5px solid currentColor; border-radius: 4px; }
.share-ratio.tall { width: 13px; height: 22px; }
.share-seg[hidden] { display: none; }
.help .share-error { color: var(--bad); font-weight: 700; }
.share-progress { width: min(100%, 200px); height: 12px; accent-color: var(--accent); }
.help .share-spoiler { margin: -4px 0 0; text-align: center; }
.share-spoiler b { color: var(--bad); }

/* The buttons, pinned to the bottom edge of the sheet. */
.share-foot {
  position: sticky;
  bottom: 0;
  display: grid;
  gap: 6px;
  margin: 0 -16px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
  background: var(--surface);
  border-top: 2px dashed var(--grid);
}
.share-foot-row { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; }
.share-foot-row .btn { min-width: 0; min-height: 52px; padding-inline: 8px; font-size: 1.05rem; }
.help .share-foot a.btn { color: var(--ink); }
.help .share-foot a.btn.primary { color: var(--primary-ink); }
.share-sheet .btn[aria-disabled="true"] { opacity: 0.4; cursor: default; }
.share-sheet .btn:focus-visible, .share-sheet .icon-btn:focus-visible, .share-sheet .link:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.share-more { display: flex; justify-content: center; gap: 20px; }
.share-more .link.small { min-height: 36px; padding: 0 4px; }
.share-more .link:disabled { opacity: 0.4; cursor: default; }
.help .share-status { font-weight: 700; color: var(--good); text-align: center; }
.help .share-status:empty { display: none; }
.share-offscreen { position: fixed; top: 0; left: -200vw; width: 10px; height: 10px; opacity: 0; }

@media (min-width: 720px) {
  .help.share-sheet { width: min(440px, calc(100vw - 32px)); max-height: calc(100svh - 32px); margin: auto; border-radius: 22px; }
  .share-wrap { padding: 20px 20px 0; }
  .share-foot { margin: 0 -20px; padding: 12px 20px 14px; }
  .share-preview[data-format="vertical"] :is(.share-shot, .share-clip-box) { height: min(46svh, 440px); }
}

@media (prefers-reduced-motion: no-preference) {
  .help.share-sheet[open] { animation: share-rise 0.22s ease-out; }
  @keyframes share-rise { from { transform: translateY(24px); opacity: 0; } }
}
