/* ============================================================================
   ADV — Share & Print  (paired with /assets/js/share.js)
   - Floating page-share button + popover + toast (every page)
   - Calculator "Share this calculation" / "Save as PDF" tool buttons
   - Print rules that turn a calculator into a clean one-page PDF
   ============================================================================ */

/* ---------------------------------------------------------------------------
   1) Floating page-share button — bottom-left (mirrors the WhatsApp float)
   --------------------------------------------------------------------------- */
.share-float-wrap {
  position: fixed;
  left: 10px;
  bottom: clamp(1rem, 2.4vw, 2rem);
  z-index: 900;
}

.share-float {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(198, 154, 77, 0.55);
  background: var(--c-ink, #0b0c0e);
  color: var(--c-gold, #c69a4d);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(11, 16, 24, 0.28), 0 2px 6px rgba(11, 16, 24, 0.2);
  transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.25s ease, color 0.25s ease;
  -webkit-tap-highlight-color: transparent;
}
.share-float svg { width: 22px; height: 22px; fill: currentColor; display: block; }
.share-float:hover {
  background: var(--c-burg-soft, #6b1f2c);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(11, 16, 24, 0.34), 0 3px 8px rgba(11, 16, 24, 0.24);
}
.share-float:focus-visible { outline: 2px solid var(--c-gold, #c69a4d); outline-offset: 3px; }
.share-float-wrap.open .share-float { background: var(--c-burg-soft, #6b1f2c); color: #fff; }

/* Popover — opens upward from the button */
.share-pop {
  position: absolute;
  left: 0;
  bottom: calc(100% + 12px);
  min-width: 200px;
  padding: 6px;
  background: #fff;
  border: 1px solid rgba(11, 16, 24, 0.10);
  border-radius: 12px;
  box-shadow: 0 24px 48px -18px rgba(11, 16, 24, 0.4);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.share-pop[hidden] { display: none; }

.share-pop-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border: 0;
  background: transparent;
  border-radius: 8px;
  font-family: var(--f-sans, system-ui, sans-serif);
  font-size: 0.9rem;
  color: var(--c-ink, #0b0c0e);
  text-decoration: none;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: background 0.18s ease, color 0.18s ease;
}
.share-pop-item svg { width: 18px; height: 18px; fill: currentColor; flex: 0 0 auto; opacity: 0.85; }
.share-pop-item:hover { background: var(--c-bone, #faf6ee); color: var(--c-burg-soft, #6b1f2c); }
.share-pop-item:focus-visible { outline: 2px solid var(--c-gold, #c69a4d); outline-offset: -2px; }

/* Toast — bottom-centre confirmation */
.share-toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(12px);
  z-index: 1000;
  background: var(--c-ink, #0b0c0e);
  color: #fff;
  font-family: var(--f-sans, system-ui, sans-serif);
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  padding: 0.7rem 1.2rem;
  border-radius: 999px;
  border: 1px solid rgba(198, 154, 77, 0.4);
  box-shadow: 0 12px 30px rgba(11, 16, 24, 0.34);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.share-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 600px) {
  .share-float { width: 48px; height: 48px; }
  .share-float svg { width: 20px; height: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  .share-float, .share-float:hover { transition: none; transform: none; }
  .share-toast { transition: opacity 0.2s ease; }
}

/* ---------------------------------------------------------------------------
   2) Calculator tool buttons — matches .calc-reset (gold outline)
   --------------------------------------------------------------------------- */
.calc-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.4rem;
}
.calc-tool {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  background: transparent;
  border: 1px solid var(--c-gold, #c69a4d);
  color: var(--c-gold, #c69a4d);
  padding: 0.7rem 1.2rem;
  font-family: var(--f-sans, system-ui, sans-serif);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.25s var(--ease, ease), color 0.25s var(--ease, ease), border-color 0.25s var(--ease, ease);
}
.calc-tool svg { width: 16px; height: 16px; fill: currentColor; }
.calc-tool:hover { background: var(--c-gold, #c69a4d); color: var(--c-ink, #0b0c0e); }
.calc-tool:focus-visible { outline: 2px solid var(--c-gold, #c69a4d); outline-offset: 2px; }
.calc-tool-share { border-color: var(--c-gold, #c69a4d); }

/* ---------------------------------------------------------------------------
   3) Print header — only rendered into print output
   --------------------------------------------------------------------------- */
.print-head { display: none; }

/* ---------------------------------------------------------------------------
   4) PRINT — clean PDF of the active calculator (scoped to calculator pages)
   --------------------------------------------------------------------------- */
@media print {
  /* keep colours legible on paper */
  body.has-calc {
    background: #fff !important;
  }

  /* chrome + page furniture */
  body.has-calc .loader,
  body.has-calc header,
  body.has-calc .site-header,
  body.has-calc .site-footer,
  body.has-calc .wa-float,
  body.has-calc .share-float-wrap,
  body.has-calc .share-toast,
  body.has-calc .footer-to-top,
  /* surrounding editorial sections on the calculator guide pages */
  body.has-calc .page-hero,
  body.has-calc .section-sm,
  body.has-calc #methodology,
  body.has-calc .j-next,
  /* interactive-only controls inside the calculator */
  body.has-calc .calc-picker,
  body.has-calc .calc-mode-bar,
  body.has-calc .calc-tools,
  body.has-calc .calc-actions,
  body.has-calc .calc-preload-note,
  body.has-calc .fx-swap-wrap,
  body.has-calc input[type="range"] {
    display: none !important;
  }

  /* show the print-only header */
  body.has-calc .print-head {
    display: flex !important;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    padding: 0 0 0.6rem;
    margin: 0 0 1rem;
    border-bottom: 1.5px solid #c69a4d;
  }
  body.has-calc .print-head__brand {
    font-family: var(--f-serif, Georgia, serif);
    font-size: 16pt;
    letter-spacing: 0.04em;
    color: #0b0c0e;
  }
  body.has-calc .print-head__meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    font-size: 8pt;
    color: #555;
    text-align: right;
  }
  body.has-calc .print-head__title { font-weight: 600; color: #0b0c0e; }

  /* let the calculator body breathe full-width and never clip */
  body.has-calc main,
  body.has-calc .container,
  body.has-calc .container-wide,
  body.has-calc .container-tight {
    max-width: none !important;
    width: auto !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  body.has-calc .section { padding: 0 !important; background: #fff !important; }
  body.has-calc .j-calc,
  body.has-calc .calc-panel {
    box-shadow: none !important;
    border: 0 !important;
    background: #fff !important;
    color: #0b0c0e !important;
    padding: 0 !important;
  }
  body.has-calc .calc-panel[hidden] { display: none !important; }

  /* tables + charts must render fully, not in a scroll box */
  body.has-calc .calc-table-scroll { overflow: visible !important; }
  body.has-calc .calc-table { font-size: 8.5pt !important; }
  body.has-calc .calc-table th,
  body.has-calc .calc-table td { padding: 3pt 5pt !important; }

  /* the slider value labels carry the inputs in print (sliders are hidden) */
  body.has-calc .calc-inputs label .val,
  body.has-calc .fx-words { color: #0b0c0e !important; }

  body.has-calc { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  @page { margin: 14mm; }
}
