/* Sdílení hry (share.js). Barvy a písma z design systému hry. */
:root {
  --share-radius: 16px;
  --share-gap: 12px;
  --share-ease: cubic-bezier(.2, .8, .2, 1);
}

/* Tlačítko na úvodní obrazovce: obíhající linka jako u aktivních políček, ikona jemně „ťukne“. */
.share-cta {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 46px;
  margin-top: 8px;
  padding: 10px 16px;
  border: 2px solid transparent;
  border-radius: 7px;
  background:
    linear-gradient(#fff, #fff) padding-box,
    conic-gradient(from var(--ring-angle), var(--ring-colors)) border-box;
  color: var(--ink);
  font: 700 14px/1.3 'Manrope', sans-serif;
  cursor: pointer;
  animation: ring-spin 4s linear infinite;
  transition: transform .15s var(--share-ease), box-shadow .2s;
}
.share-cta:hover { box-shadow: 0 6px 18px #2867302a; transform: translateY(-1px); }
.share-cta:active { transform: translateY(0); }
.share-cta:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.share-cta-icon { width: 20px; height: 20px; flex: 0 0 20px; color: var(--action); animation: share-nudge 3.6s var(--share-ease) infinite; }
@keyframes share-nudge {
  0%, 72%, 100% { transform: translateY(0); }
  80% { transform: translateY(-3px); }
  88% { transform: translateY(0); }
  94% { transform: translateY(-1.5px); }
}

/* Odkaz v patičce: stejný styl jako Jak hrát, Ovládání, O hře. */
.footer-help-links .share-footer-link { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; }
.footer-help-links .share-footer-link span { display: inline; }
.share-footer-link svg { width: 14px; height: 14px; flex: 0 0 14px; filter: drop-shadow(0 1px 3px #092857); }

/* Okno: na počítači uprostřed, na telefonu vyjede zespodu. */
.share-dialog {
  width: min(480px, calc(100vw - 32px));
  max-width: none;
  max-height: calc(100dvh - 32px);
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: var(--share-radius);
  background: #fff;
  color: var(--ink);
  box-shadow: 0 30px 80px #0928574d;
  overflow: auto;
  overscroll-behavior: contain;
}
.share-dialog[open] { animation: share-in .32s var(--share-ease); }
.share-dialog.is-closing { animation: share-out .22s ease-in forwards; }
.share-dialog::backdrop { background: #061a3a8c; backdrop-filter: blur(3px); animation: share-fade .3s ease; }
.share-dialog.is-closing::backdrop { animation: share-fade .22s ease-in reverse forwards; }
@keyframes share-in { from { opacity: 0; transform: translateY(14px) scale(.97); } }
@keyframes share-out { to { opacity: 0; transform: translateY(10px) scale(.98); } }
@keyframes share-fade { from { opacity: 0; } }

.share-sheet { position: relative; padding: 22px 22px 18px; border-top: 5px solid var(--action); border-radius: inherit; }
.share-grabber { display: none; }
.share-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--share-gap); }
.share-kicker { margin: 0 0 4px; color: var(--action); font: 800 11px/1.2 'Manrope', sans-serif; letter-spacing: .1em; text-transform: uppercase; }
.share-head h2 { margin: 0; font: 800 23px/1.15 'Manrope', sans-serif; color: var(--ink); }
.share-lead { margin: 6px 0 0; color: var(--muted); font-size: 14px; line-height: 1.45; }
.share-close {
  flex: 0 0 44px; width: 44px; height: 44px; margin: -8px -10px 0 0; padding: 10px;
  border: 0; border-radius: 50%; background: none; color: var(--ink); cursor: pointer;
}
.share-close:hover { background: var(--surface-soft); }
.share-close:focus-visible { outline: none; background: var(--surface-soft); box-shadow: 0 0 0 2px #49943c80; }
.share-sheet:focus { outline: none; }
.share-close svg { width: 100%; height: 100%; }

.share-preview {
  display: flex; align-items: center; gap: 12px; margin: 16px 0 18px; padding: 8px;
  border: 1px solid var(--line); border-radius: 10px; color: inherit; text-decoration: none;
  transition: border-color .2s;
}
.share-preview:hover { border-color: var(--brand-green); }
.share-preview img { width: 96px; height: auto; aspect-ratio: 1200 / 630; border-radius: 6px; object-fit: cover; flex: 0 0 96px; }
.share-preview span { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.share-preview b { font-size: 13px; line-height: 1.3; }
.share-preview small { color: var(--muted); font-size: 12px; }

/* Mřížka sítí: barevná ikona, při najetí vyskočí; postupný nástup při otevření. */
.share-grid { display: grid; grid-template-columns: repeat(var(--cols, 4), minmax(0, 1fr)); gap: 14px 8px; margin: 0; padding: 0; list-style: none; }
.share-grid li { animation: share-pop .42s var(--share-ease) both; animation-delay: calc(var(--i) * 35ms + 80ms); }
@keyframes share-pop { from { opacity: 0; transform: translateY(10px) scale(.9); } }
.share-target {
  display: flex; flex-direction: column; align-items: center; gap: 7px; min-height: 44px; padding: 4px 0;
  border-radius: 10px; color: var(--ink); font-size: 12px; font-weight: 600; text-decoration: none; text-align: center;
}
.share-icon {
  display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%;
  background: var(--brand); color: #fff; box-shadow: 0 6px 16px color-mix(in srgb, var(--brand) 35%, transparent);
  transition: transform .2s var(--share-ease), box-shadow .2s;
}
.share-icon svg { width: 26px; height: 26px; }
.share-target:hover .share-icon, .share-target:focus-visible .share-icon { transform: translateY(-3px) scale(1.06); box-shadow: 0 10px 22px color-mix(in srgb, var(--brand) 45%, transparent); }
.share-target:active .share-icon { transform: scale(.94); }
.share-target:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.share-link { display: flex; gap: 8px; margin-top: 20px; }
.share-link input {
  flex: 1 1 auto; min-width: 0; min-height: 46px; padding: 0 12px; border: 1px solid var(--line); border-radius: 7px;
  background: var(--surface-soft); color: var(--ink); font: inherit; font-size: 14px;
}
.share-copy {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 7px; flex: 0 0 auto;
  min-height: 46px; min-width: 140px; padding: 0 16px; border: 0; border-radius: 7px;
  background: var(--action); color: #fff; font: 700 14px/1 'Manrope', sans-serif; cursor: pointer; transition: background .2s;
}
.share-copy:hover { background: var(--action-hover); }
.share-copy svg { width: 18px; height: 18px; flex: 0 0 18px; }
.share-check-icon { display: none; }
.share-copy.is-copied { background: var(--brand-green); }
.share-copy.is-copied .share-copy-icon { display: none; }
.share-copy.is-copied .share-check-icon { display: block; stroke-dasharray: 24; stroke-dashoffset: 24; animation: share-check .35s var(--share-ease) forwards; }
@keyframes share-check { to { stroke-dashoffset: 0; } }

.share-native {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 46px; margin-top: 10px;
  border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--ink); font: 700 14px/1 'Manrope', sans-serif; cursor: pointer;
}
.share-native:hover { border-color: var(--brand-green); }
.share-native svg { width: 20px; height: 20px; }
.share-status { min-height: 18px; margin: 10px 0 0; color: var(--muted); font-size: 12px; text-align: center; }

/* Telefon: spodní panel přes celou šířku s úchytem. */
@media (max-width: 560px) {
  .share-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .share-dialog {
    width: 100%; max-height: calc(100dvh - 24px); margin: auto 0 0;
    border-radius: var(--share-radius) var(--share-radius) 0 0;
  }
  .share-dialog[open] { animation: share-up .36s var(--share-ease); }
  .share-dialog.is-closing { animation: share-down .22s ease-in forwards; }
  @keyframes share-up { from { transform: translateY(100%); } }
  @keyframes share-down { to { transform: translateY(100%); } }
  .share-sheet { padding: 10px 18px calc(16px + env(safe-area-inset-bottom)); border-top: 0; }
  .share-grabber { display: block; width: 40px; height: 4px; margin: 0 auto 14px; border-radius: 2px; background: var(--line); }
  .share-head h2 { font-size: 21px; }
  .share-grid { gap: 12px 4px; }
  .share-icon { width: 50px; height: 50px; }
  .share-copy { min-width: 0; }
}
@media (max-width: 340px) {
  .share-grid { gap: 12px 2px; }
  .share-icon { width: 44px; height: 44px; }
  .share-icon svg { width: 22px; height: 22px; }
  .share-target { font-size: 11px; }
  .share-copy span { display: none; }
}
/* Nízký displej naležato: méně vertikálních mezer, náhled schovaný. */
@media (max-height: 500px) and (min-width: 500px) {
  .share-dialog { width: min(620px, calc(100vw - 32px)); }
  .share-sheet { padding: 14px 18px 12px; }
  .share-preview { display: none; }
  .share-head { margin-bottom: 12px; }
  .share-grid { grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 8px 4px; }
  .share-icon { width: 44px; height: 44px; }
  .share-icon svg { width: 22px; height: 22px; }
  .share-link { margin-top: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .share-cta, .share-cta-icon, .share-grid li, .share-dialog[open], .share-dialog.is-closing,
  .share-dialog::backdrop, .share-copy.is-copied .share-check-icon { animation: none; }
  .share-copy.is-copied .share-check-icon { stroke-dashoffset: 0; }
}
