/*
 * Ihsabha — share-result.css
 * Styles for the "Result Actions" bar (Copy Result / Share Result /
 * Copy Link) injected by share-result.js, plus the lightweight
 * fallback share popover. Uses the site's existing design tokens
 * (--brand, --line, --surface, --ink, --muted, --radius) so it matches
 * every category color scheme automatically without extra overrides.
 * No layout/identity changes elsewhere on the site — see brief §25.
 */

.ihs-share-actions {
  display: none; /* shown only once the paired .result gets .show */
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.result.show + .ihs-share-actions {
  display: flex;
}

/* De-duplicate against a calculator's own existing copy button (a small
   number of tools already render one inside .result via the pre-existing
   copy-feedback.js system — see brief §5/§18: reuse, never duplicate). */
.result:has([data-role="copy-btn"]) + .ihs-share-actions .ihs-copy-result {
  display: none;
}

.ihs-share-btn {
  flex: 1 1 auto;
  min-width: 130px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 14px;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  transition: background-color .15s ease, transform .1s ease;
}

.ihs-share-btn:hover {
  background: var(--bg);
}

.ihs-share-btn:active {
  transform: scale(0.98);
}

.ihs-share-btn:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.ihs-share-primary {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
  flex-basis: 100%;
  order: -1;
}

.ihs-share-primary:hover {
  filter: brightness(0.95);
  background: var(--brand);
}

.ihs-share-image:disabled {
  opacity: 0.7;
  cursor: default;
}

/* Fallback share popover */
.ihs-share-menu {
  position: absolute;
  z-index: 1000;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius, 16px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 200px;
  max-width: min(90vw, 280px);
}

.ihs-share-menu-item {
  display: block;
  width: 100%;
  text-align: start;
  background: transparent;
  border: none;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  box-sizing: border-box;
}

.ihs-share-menu-item:hover,
.ihs-share-menu-item:focus-visible {
  background: var(--bg);
  outline: none;
}

.ihs-share-menu-close {
  position: absolute;
  top: 6px;
  inset-inline-end: 6px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  background: var(--bg);
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  line-height: 1;
}

@media (max-width: 480px) {
  .ihs-share-btn {
    min-width: 100%;
    flex-basis: 100%;
  }
}
