/* Share rail on every public page (docs/ai/design.md), markup from tools/seo/build.py, shown by /js/share.js outside frames.
   It never changes the page layout: every rule here styles the rail itself, nothing else moves for it.
   Wide screens with a free margin: four round links on a cream pill at the inline-start edge, vertically centered.
   Elsewhere: a clear tab flush with that edge (--share-tab, 40 to 44px wide, 56px tall, a 20px share icon);
   a tap opens the four links as a popover beside it until it closes. On phones the tab overlaps the edge of the
   content and the page scrolls under it.
   Below the wide size the rail box spans the viewport (without its scrollbar) and lets every pointer through, so 100%
   in --share-tab is the width the page lays out in; only the tab and the open links take pointers */
.share-rail{--share-tab:40px;position:fixed;z-index:30;inset-inline:0;top:50%;transform:translateY(-50%);pointer-events:none;
  font-family:Onest,sans-serif;-webkit-tap-highlight-color:transparent}
.share-rail[hidden]{display:none}
.share-handle,.share-links{pointer-events:auto}
.share-handle{display:grid;place-items:center;width:var(--share-tab);height:56px;margin:0;margin-inline-start:env(safe-area-inset-left,0px);padding:0;border:0;
  border-start-end-radius:12px;border-end-end-radius:12px;background:var(--cream,#fffaf0);box-shadow:var(--shadow,0 8px 22px #503c1433);color:#183338;font:inherit;cursor:pointer}
.share-handle .icon{display:block;width:20px;height:20px}
.share-handle[aria-expanded="true"]{color:#d95a35}
.share-links{list-style:none;margin:0;padding:4px;display:none;flex-direction:column;gap:4px;border-radius:26px;background:var(--cream,#fffaf0);box-shadow:0 6px 18px #503c1429;
  position:absolute;inset-inline-start:calc(env(safe-area-inset-left,0px) + var(--share-tab) + 8px);top:50%;transform:translateY(-50%)}
.share-handle[aria-expanded="true"]+.share-links{display:flex}
.share-link{display:grid;place-items:center;width:44px;height:44px;border-radius:50%;color:#183338;text-decoration:none}
.share-link .icon{display:block;width:22px;height:22px}
.share-link[data-network="facebook"]{--brand:#0866ff}
.share-link[data-network="reddit"]{--brand:#ff4500}
.share-link[data-network="threads"],.share-link[data-network="x"]{--brand:#000}
/* Network color only on hover and focus */
.share-link:hover,.share-link:focus-visible{background:var(--brand);color:#fff}
.share-link:focus-visible,.share-handle:focus-visible{outline:3px solid #d95a35;outline-offset:2px}
@media(hover:hover){.share-handle:hover{color:#d95a35}}
@media(prefers-reduced-motion:no-preference){.share-link,.share-handle{transition:background-color .15s,color .15s}}
@media print{.share-rail{display:none!important}}

/* Content pages scroll under the tab. It is 44px where the margin beside the nearest content holds it with 2px to
   spare: the card (main is 840px wide with a 14px gutter), the footer text (20px gutter, a 1040px column) and from
   1180px the railway stripe (50% - 540px); else 40px, over the edge of the card.
   The full rail from 1264px and taller than 500px, 16px clear of the stripe */
.site>.share-rail{--share-tab:clamp(40px,min(max(0px,(100% - 840px) / 2) + 12px,max(0px,(100% - 1080px) / 2) + 18px),44px)}
@media(min-width:1180px){
  .site>.share-rail{--share-tab:clamp(40px,min(max(0px,(100% - 840px) / 2) + 12px,max(0px,(100% - 1080px) / 2) + 18px,50% - 542px),44px)}
}
@media(min-width:1264px) and (min-height:501px){
  .site>.share-rail{inset-inline:16px auto}
  .site>.share-rail .share-handle{display:none}
  .site>.share-rail .share-links{display:flex;position:static;transform:none}
}

/* Game page: the rail rests on calm screens only (start and results), never over a run, a dialog or the loading screen.
   The start screen and the results do not scroll, so the tab sits at one height on both, 128px from the top: under
   the start screen's top row (and the language offer row phones put under it), above Play in short landscape, over
   no text or control. It is 44px where the margin beside the start screen's columns holds it (20px on phones, the
   520px column from 600px, 28px or the centered 420px column on short screens), else 40px.
   The results card leaves no room beside it on phones and short screens up to 803px: the tab hides there */
#game:not([data-screen="start"],[data-screen="over"])~.share-rail,#game:has(>#modal:not([hidden]))~.share-rail{display:none}
#game~.share-rail{--share-tab:40px;top:calc(128px + max(0px,env(safe-area-inset-top,0px) - 24px));transform:none}
@media(min-width:600px){#game~.share-rail{--share-tab:clamp(40px,(100% - 520px) / 2 - 2px,44px)}}
@media(max-height:500px){#game~.share-rail{--share-tab:clamp(40px,26px + max(0px,(100% - 91px) / 4 - 210px),44px)}}
@media(max-width:543px){#game[data-screen="over"]~.share-rail{display:none}}
@media(max-height:500px) and (max-width:803px){#game[data-screen="over"]~.share-rail{display:none}}
@media(min-width:1200px) and (min-height:501px){
  #game~.share-rail{inset-inline:16px auto;top:50%;transform:translateY(-50%)}
  #game~.share-rail .share-handle{display:none}
  #game~.share-rail .share-links{display:flex;position:static;transform:none}
}
