/* ============================================================
   Casvia Embed System
   - Embed mode (?embed=1): hide chrome, show only calculator
   - Embed modal: copy iframe code to embed on other sites
   ============================================================ */

/* ---------- Embed Mode ---------- */
body.embed-mode .site-header,
body.embed-mode .site-footer,
body.embed-mode .breadcrumb,
body.embed-mode .mobile-result-bar,
body.embed-mode .trust-bar,
body.embed-mode .section:not(.calculator-section):not(.result-section),
body.embed-mode .actions,
body.embed-mode .report-actions,
body.embed-mode .sticky-result,
body.embed-mode .page-intro,
body.embed-mode h1,
body.embed-mode .calculator-intro,
body.embed-mode .faq-section,
body.embed-mode .related-section,
body.embed-mode .sources-section,
body.embed-mode .methodology-section,
body.embed-mode .example-section,
body.embed-mode .how-it-works-section,
body.embed-mode .uk-specific-section,
body.embed-mode .what-next-section,
body.embed-mode .insight-card,
body.embed-mode .what-this-means {
  display: none !important;
}

body.embed-mode {
  background: var(--bg);
  padding: 0;
  margin: 0;
}

body.embed-mode main {
  padding: 0;
  max-width: 100%;
}

body.embed-mode .container {
  max-width: 100%;
  padding: 16px;
}

body.embed-mode .calculator-shell,
body.embed-mode .calculator-section {
  margin: 0;
  padding: 0;
}

body.embed-mode .result-card {
  margin-top: 12px;
}

/* Embed mode powered-by footer (replaces hidden site-footer) */
body.embed-mode::after {
  content: "Calculator by Casvia.uk — Free UK financial calculators";
  display: block;
  text-align: center;
  font-size: 0.75rem;
  color: var(--ink-soft);
  padding: 10px 16px;
  border-top: 1px solid var(--line);
  margin-top: 8px;
}

/* ---------- Embed Button ---------- */
.embed-btn {
  position: relative;
}

.embed-btn .embed-icon {
  display: inline-block;
  margin-right: 4px;
  font-size: 1rem;
  line-height: 1;
}

/* ---------- Embed Modal ---------- */
.embed-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(14, 46, 43, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  animation: embedFadeIn 0.2s ease;
}

.embed-modal-overlay.active {
  display: flex;
}

@keyframes embedFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.embed-modal {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 28px;
  max-width: 600px;
  width: 100%;
  box-shadow: 0 24px 64px rgba(14, 46, 43, 0.25);
  position: relative;
  animation: embedSlideUp 0.25s ease;
}

@keyframes embedSlideUp {
  from { transform: translateY(16px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.embed-modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  border: none;
  background: var(--surface-2);
  color: var(--ink-soft);
  font-size: 1.4rem;
  line-height: 1;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}

.embed-modal-close:hover {
  background: var(--line);
  color: var(--ink);
}

.embed-modal h3 {
  margin: 0 0 8px;
  font-size: 1.3rem;
  color: var(--ink);
  padding-right: 40px;
}

.embed-modal p {
  margin: 0 0 20px;
  color: var(--ink-soft);
  font-size: 0.95rem;
  line-height: 1.5;
}

.embed-code-block {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 16px;
  position: relative;
}

.embed-code-block pre {
  margin: 0;
  font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
  font-size: 0.78rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--ink);
  max-height: 140px;
  overflow-y: auto;
  padding-right: 70px;
}

.embed-copy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 6px 14px;
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.embed-copy-btn:hover {
  background: #0d5f58;
}

.embed-copy-btn:active {
  transform: scale(0.97);
}

.embed-copy-btn.copied {
  background: var(--ok);
}

.embed-preview-note {
  font-size: 0.82rem;
  color: var(--ink-soft);
  margin-bottom: 16px;
  padding: 10px 14px;
  background: var(--note-info-bg);
  border-radius: 8px;
  border-left: 3px solid var(--info-ink);
}

.embed-powered-by {
  text-align: center;
  font-size: 0.8rem;
  color: var(--ink-soft);
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.embed-powered-by a {
  color: var(--brand);
  text-decoration: none;
  font-weight: 600;
}

.embed-powered-by a:hover {
  text-decoration: underline;
}

/* ---------- Mobile ---------- */
@media (max-width: 480px) {
  .embed-modal {
    padding: 20px;
  }

  .embed-modal h3 {
    font-size: 1.15rem;
  }

  .embed-code-block pre {
    font-size: 0.72rem;
    max-height: 120px;
  }
}

/* ---------- Dark mode ---------- */
:root[data-theme="dark"] .embed-modal-overlay {
  background: rgba(0, 0, 0, 0.65);
}

:root[data-theme="dark"] .embed-code-block {
  background: var(--bg);
}

:root[data-theme="dark"] .embed-modal-close {
  background: var(--surface-2);
}
