/* QuestionTheBill.com — shareable cards: the Share button, the share dialog and card.html.
   Uses the site's variables when they exist; the fallbacks are the brand colors. */
.sharebtn, .sharedlg, .cardpage {
  --sh-ink: var(--ink, #0a0f2c);
  --sh-muted: var(--muted, #525a7a);
  --sh-rule: var(--rule, #d5dbef);
  --sh-card: var(--card, #ffffff);
  --sh-paper: var(--paper, #ffffff);
  --sh-accent: var(--accent, #2236f5);
  --sh-soft: var(--accent-soft, #e4e8ff);
  --sh-sans: var(--sans, "Hanken Grotesk", "Helvetica Neue", Arial, system-ui, sans-serif);
  --sh-display: var(--serif, "Bricolage Grotesque", "Arial Black", "Helvetica Neue", Arial, sans-serif);
  --sh-mono: var(--mono, "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace);
}

/* ---------- the small Share button ---------- */
.sharebtn {
  display: inline-flex; align-items: center; gap: .4em;
  min-height: 44px; padding: 0 1em; margin: 0;
  font: 500 .8125rem/1 var(--sh-mono); letter-spacing: .06em; text-transform: uppercase;
  color: var(--sh-accent); background: var(--sh-card);
  border: 1.5px solid var(--sh-accent); border-radius: 999px; cursor: pointer;
  transition: background-color .15s, color .15s;
}
.sharebtn svg { flex: none; }
.sharebtn:hover { background: var(--sh-soft); }
.sharebtn:active { background: var(--sh-accent); color: #fff; }
.sharebtn:focus-visible { outline: 3px solid var(--sh-accent); outline-offset: 2px; }

/* ---------- dialog ---------- */
.sharedlg {
  width: min(980px, calc(100vw - 24px)); max-width: none; max-height: calc(100dvh - 24px);
  margin: auto; padding: 0; border: 0; border-radius: 14px;
  background: var(--sh-card); color: var(--sh-ink); font-family: var(--sh-sans);
  box-shadow: 0 24px 80px rgba(10, 15, 44, .28);
  overflow: auto; overscroll-behavior: contain;
}
.sharedlg::backdrop { background: rgba(10, 15, 44, .55); }
.sharedlg-in { display: flex; flex-direction: column; min-height: 0; }
.sharedlg-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 12px 12px 24px; border-bottom: 1px solid var(--sh-rule);
  position: sticky; top: 0; background: var(--sh-card); z-index: 1;
}
.sharedlg-head h2 {
  margin: 0; font: 800 1.25rem/1.2 var(--sh-display); letter-spacing: -.02em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sharedlg-x {
  flex: none; width: 44px; height: 44px; border: 0; border-radius: 8px; background: transparent;
  color: var(--sh-ink); font-size: 1.75rem; line-height: 1; cursor: pointer;
}
.sharedlg-x:hover { background: var(--sh-soft); }
.sharedlg-body { padding: 20px 24px; }
.sharedlg-foot { display: flex; justify-content: flex-end; padding: 12px 24px 20px; border-top: 1px solid var(--sh-rule); }
.share-wait { margin: 40px 0; text-align: center; color: var(--sh-muted); }

/* ---------- shared controls (dialog and card.html) ---------- */
.share-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(260px, 1fr); gap: 24px; align-items: start; }
.share-prev {
  margin: 0; padding: 14px; display: flex; justify-content: center; align-items: center;
  background: var(--sh-soft); border-radius: 10px; min-width: 0;
}
.share-prev canvas {
  display: block; width: auto; height: auto; max-width: 100%;
  max-height: min(62vh, 560px);
  border-radius: 4px; box-shadow: 0 2px 0 var(--sh-rule), 0 10px 30px rgba(10, 15, 44, .14);
  background: #fff;
}
.is-story .share-prev canvas { max-height: min(68vh, 640px); }
.share-side { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

.share-size {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px;
  border: 1px solid var(--sh-rule); border-radius: 10px; background: var(--sh-paper);
}
.share-size button {
  min-height: 52px; border: 0; border-radius: 7px; background: transparent; cursor: pointer;
  font: 600 1rem/1.15 var(--sh-sans); color: var(--sh-ink);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.share-size button small { font: 500 .6875rem/1 var(--sh-mono); letter-spacing: .04em; color: var(--sh-muted); }
.share-size button[aria-pressed="true"] { background: var(--sh-ink); color: #fff; }
.share-size button[aria-pressed="true"] small { color: #c9cff0; }

.share-acts { display: flex; flex-direction: column; gap: 8px; }
.share-acts button, .sharedlg-foot button {
  min-height: 48px; padding: 0 18px; border-radius: 8px; cursor: pointer;
  font: 600 1rem/1 var(--sh-sans); color: var(--sh-accent);
  background: var(--sh-card); border: 1.5px solid var(--sh-accent);
}
.share-acts button:hover, .sharedlg-foot button:hover { background: var(--sh-soft); }
.share-acts .share-main { background: var(--sh-accent); color: #fff; }
.share-acts .share-main:hover { background: var(--sh-ink); border-color: var(--sh-ink); }
.share-acts button[hidden] { display: none; }

.share-url { display: flex; flex-direction: column; gap: 6px; }
.share-url span, .share-lab { margin: 0; font: 500 .75rem/1.2 var(--sh-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--sh-muted); }
.share-url input {
  min-height: 44px; width: 100%; box-sizing: border-box; padding: 0 12px;
  font: 400 .875rem/1 var(--sh-mono); color: var(--sh-ink);
  background: var(--sh-paper); border: 1px solid var(--sh-rule); border-radius: 8px;
}
.share-status { margin: 0; min-height: 1.4em; font-size: .9375rem; color: var(--sh-accent); font-weight: 600; }
.share-status:empty { min-height: 0; }

.share-links { list-style: none; margin: -6px 0 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.share-links a {
  display: flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 6px;
  border: 1px solid var(--sh-rule); border-radius: 8px; background: var(--sh-paper);
  font: 600 .9375rem/1 var(--sh-sans); color: var(--sh-ink); text-decoration: none;
}
.share-links a:hover { border-color: var(--sh-accent); color: var(--sh-accent); }
.share-page { margin: 0; }
.share-page a { font-weight: 600; color: var(--sh-accent); }
.share-note { margin: 0; font-size: .8125rem; line-height: 1.45; color: var(--sh-muted); }

.sharedlg button:focus-visible, .sharedlg a:focus-visible, .sharedlg input:focus-visible,
.cardpage button:focus-visible, .cardpage a:focus-visible, .cardpage input:focus-visible { outline: 3px solid var(--sh-accent); outline-offset: 2px; }

.sharedlg .vh, .cardpage .vh { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- card.html ---------- */
.cardpage { max-width: 1080px; margin: 0 auto; padding: 32px 16px 64px; color: var(--sh-ink); font-family: var(--sh-sans); }
.cardpage .card-k { margin: 0 0 6px; font: 500 .75rem/1.2 var(--sh-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--sh-accent); }
.cardpage h1 { margin: 0 0 24px; font: 800 clamp(2rem, 6vw, 3.25rem)/1.05 var(--sh-display); letter-spacing: -.035em; }
.cardpage .share-prev { padding: 20px; }
.cardpage .share-prev canvas { max-height: min(78vh, 760px); }
.cardpage .is-story .share-prev canvas { max-height: min(84vh, 900px); }

/* ---------- phones ---------- */
@media (max-width: 720px) {
  .share-grid { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .share-prev { padding: 10px; }
  .share-prev canvas { max-height: 46vh; }
  .is-story .share-prev canvas { max-height: 52vh; }
  .cardpage .share-prev canvas { max-height: 60vh; }
  .cardpage .is-story .share-prev canvas { max-height: 70vh; }
  .sharedlg { width: 100vw; max-height: 100dvh; height: 100dvh; border-radius: 0; }
  .sharedlg-body { padding: 14px 16px; }
  .sharedlg-head { padding-left: 16px; }
  .sharedlg-foot { padding: 12px 16px 16px; }
  .sharedlg-foot button { width: 100%; }
  .share-links { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) { .sharebtn { transition: none; } }
body.card-body { background: var(--paper, #ffffff); color: var(--ink, #0a0f2c); }
