/* Copy and share (share.js). The buttons under a result take the colours of the surface they sit on; the pop-up, menu
   and notice float above the page in midnight and gold, the same everywhere. Tokens come from app.css. */

/* Under a result: the label on the left, the buttons on the right. */
.answer-foot {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-2) var(--s-4);
  width: 100%; margin-top: var(--s-3);
}
.msg .answer-foot { max-width: var(--bubble-max); }
.answer-foot .label-bot, .oracle-result .answer-foot .label-bot { margin: 0; }
.answer-foot .share-bar { margin-left: auto; }
.oracle-result .answer-foot { margin-top: var(--s-5); padding-top: var(--s-4); border-top: 1px solid var(--border-subtle); }

.share-bar { display: flex; gap: var(--s-2); -webkit-user-select: none; user-select: none; }
.share-btn {
  display: inline-flex; align-items: center; gap: 7px; min-height: 40px; padding: 0 var(--s-4) 0 var(--s-3);
  border: 1px solid color-mix(in srgb, var(--color-antique-gold) 55%, transparent); border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--bg-page) 55%, transparent); color: var(--text-primary); cursor: pointer;
  font: 600 var(--t-small)/1 var(--font-sans);
  transition: background var(--d-base) var(--ease-out), border-color var(--d-base) var(--ease-out), transform var(--d-fast) var(--ease-out);
}
.share-btn:hover, .share-btn[aria-expanded="true"] {
  border-color: var(--color-antique-gold);
  background: color-mix(in srgb, var(--color-antique-gold) 22%, transparent);
}
.share-btn:active { transform: scale(.96); }
body.page-home .share-btn { -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.dlg > .share-bar { margin-top: var(--s-4); }
/* Under a Workbook lesson, on the parchment sheet: midnight ink on parchment, like a reply. */
.wb-share {
  --bg-page: var(--color-parchment); --text-primary: var(--color-midnight);
  justify-content: flex-end; max-width: var(--measure); margin-top: var(--s-5);
}
.wb-share .share-btn { border-color: rgba(125, 98, 52, .55); }
.wb-share .share-btn:hover, .wb-share .share-btn[aria-expanded="true"] { border-color: #7D6234; background: rgba(125, 98, 52, .14); }

.share-icon {
  width: 17px; height: 17px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}
.share-icon .is-dots { stroke-width: 3; }

/* Floating pieces. They are placed by share.js. */
.share-pop, .share-menu, .share-toast {
  position: fixed; margin: 0; -webkit-user-select: none; user-select: none;
  color: var(--color-moonlight); font-family: var(--font-sans);
  background: color-mix(in srgb, var(--color-deep-midnight) 92%, var(--color-mystic-plum));
  -webkit-backdrop-filter: blur(16px) saturate(1.1); backdrop-filter: blur(16px) saturate(1.1);
  border: 1px solid color-mix(in srgb, var(--color-antique-gold) 45%, transparent);
  box-shadow: 0 2px 4px rgba(11, 16, 32, .4), 0 14px 36px -6px rgba(11, 16, 32, .65);
}
.share-pop :focus-visible, .share-menu :focus-visible { outline: 2px solid var(--color-soft-gold); outline-offset: -2px; }

.share-pop { z-index: 40; display: flex; gap: 2px; padding: 4px; border-radius: var(--r-pill); animation: share-in var(--d-base) var(--ease-out); }
.share-pop-btn {
  display: inline-flex; align-items: center; gap: 7px; min-height: 40px; padding: 0 var(--s-4);
  border: 0; border-radius: var(--r-pill); background: transparent; color: inherit; cursor: pointer;
  font: 600 var(--t-small)/1 var(--font-sans); white-space: nowrap;
}
.share-pop-btn + .share-pop-btn { position: relative; }
.share-pop-btn + .share-pop-btn::before {
  content: ""; position: absolute; left: -1px; top: 10px; bottom: 10px; width: 1px;
  background: color-mix(in srgb, var(--color-antique-gold) 35%, transparent);
}
.share-pop-btn:hover, .share-pop-btn[aria-expanded="true"] { background: color-mix(in srgb, var(--color-antique-gold) 24%, transparent); }
.share-pop-btn .share-icon { color: var(--color-soft-gold); }

.share-menu {
  z-index: 41; width: min(280px, calc(100vw - 16px)); max-height: calc(100vh - 16px); overflow-y: auto;
  padding: var(--s-3); border-radius: var(--r-lg); animation: share-in var(--d-base) var(--ease-out);
}
.share-menu-title {
  margin: 0 0 var(--s-2) var(--s-1); font-weight: 600; font-size: var(--t-label); letter-spacing: .08em;
  font-variant-caps: all-small-caps; color: var(--color-soft-gold);
}
.share-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.share-menu .share-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 68px; padding: var(--s-2) var(--s-1); border: 1px solid transparent; border-radius: var(--r-md);
  background: color-mix(in srgb, var(--color-moonlight) 6%, transparent); color: var(--color-moonlight); cursor: pointer;
  font: 500 var(--t-micro)/1.2 var(--font-sans); text-align: center; text-decoration: none;
  transition: background var(--d-fast) var(--ease-out), border-color var(--d-fast) var(--ease-out);
}
.share-menu .share-item:hover {
  background: color-mix(in srgb, var(--color-antique-gold) 20%, transparent);
  border-color: color-mix(in srgb, var(--color-antique-gold) 60%, transparent); color: var(--color-moonlight);
}
.share-menu .share-item .share-icon { width: 22px; height: 22px; color: var(--color-soft-gold); }
.share-menu .share-item--wide { grid-column: 1 / -1; flex-direction: row; min-height: 44px; font-size: var(--t-small); }

.share-toast {
  z-index: 42; left: 50%; bottom: calc(var(--s-6) + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  display: flex; align-items: center; gap: var(--s-2); width: max-content; max-width: calc(100vw - 32px);
  padding: var(--s-3) var(--s-5); border-radius: var(--r-pill); font-size: var(--t-small); line-height: 1.35;
  animation: share-fade var(--d-base) var(--ease-out); pointer-events: none;
}
.share-toast:empty { visibility: hidden; }
.share-toast .share-icon { color: var(--color-soft-gold); }

@keyframes share-in { from { opacity: 0; transform: translateY(4px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes share-fade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .share-pop, .share-menu, .share-toast { animation: none; }
}
