/* Embeds for the free tools. Added to every tool page by scripts/tools-embed.cjs, after tool-theme.css.
   Two parts:
   1. "Embed this tool" section on the tool page (code box, options, preview).
   2. Embed view: the same page opened as /tools/<tool>?embed=1 inside another site's iframe. The inline
      NC-EMBED script in <head> adds html.nc-embed before first paint; this hides everything but the
      tool itself (upload card + readout). Hidden parts stay in the DOM, so each tool's app.js still finds
      every element it expects. Colours are tool tokens only, so both themes work. */

/* 1. Embed section on the tool page */
.embed-section { padding: 96px 0; background: var(--bg-elev); border-top: 1px solid var(--line); }
.embed-grid { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); gap: 56px; align-items: start; }
.embed-copy h2 { margin: 12px 0 20px; font-size: clamp(32px, 4vw, 50px); line-height: 1.05; max-width: 16ch; }
.embed-copy > p { max-width: 46ch; font-size: 17px; line-height: 1.55; }
.embed-points { display: grid; gap: 10px; margin: 24px 0; padding: 0; list-style: none; }
.embed-points li { position: relative; padding-left: 26px; color: var(--ink-soft); font-size: 15px; line-height: 1.5; }
.embed-points li::before { content: ""; position: absolute; left: 2px; top: 6px; width: 12px; height: 7px; border: solid var(--mint-ink); border-width: 0 0 2px 2px; transform: rotate(-45deg); }
.embed-copy .embed-terms { font-size: 14px; color: var(--ink-muted); }
.embed-terms a, .embed-note a { color: var(--accent-deep); text-decoration: underline; text-underline-offset: 2px; }

.embed-box { padding: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.embed-options { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; margin-bottom: 16px; }
.embed-options fieldset { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0; padding: 0; border: 0; }
.embed-options legend { float: left; margin-right: 6px; color: var(--ink-muted); font: 500 12px/1.4 var(--font-mono); letter-spacing: .06em; text-transform: uppercase; }
.embed-choice { position: relative; display: inline-flex; }
.embed-choice input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.embed-choice span { display: inline-flex; align-items: center; min-height: 36px; padding: 6px 14px; border: 1px solid var(--line-strong); border-radius: var(--r-pill); background: var(--bg); color: var(--ink-soft); font-size: 13.5px; font-weight: 500; }
.embed-choice input:checked + span { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.embed-choice input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.embed-check { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-soft); font-size: 14px; cursor: pointer; }
.embed-check input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }

.embed-code-label { display: block; margin-bottom: 8px; color: var(--ink-muted); font: 500 12px/1.4 var(--font-mono); letter-spacing: .06em; text-transform: uppercase; }
.embed-code { display: block; box-sizing: border-box; width: 100%; min-height: 170px; padding: 14px 16px; resize: vertical; font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--bg); color: var(--ink); font: 12.5px/1.6 var(--font-mono); white-space: pre; overflow: auto; tab-size: 2; }
.embed-code:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.embed-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.embed-actions .button { width: auto; flex: 1 1 160px; }
.embed-status { min-height: 1.5em; margin-top: 10px; color: var(--mint-ink); font-size: 13.5px; font-weight: 500; }
.embed-note { margin-top: 4px; color: var(--ink-muted); font-size: 13px; line-height: 1.5; }

.embed-preview { margin-top: 40px; }
.embed-preview-frame { max-width: 860px; margin: 0 auto; padding: 16px; border: 1px dashed var(--line-strong); border-radius: var(--r-lg); background: var(--bg); }
.embed-preview-frame iframe { display: block; width: 100%; height: 900px; border: 0; }
.embed-preview-frame .embed-credit { margin: 8px 0 0; color: var(--ink-soft); font-size: 14px; text-align: center; }
.embed-preview-frame .embed-credit a { color: var(--accent-deep); text-decoration: underline; text-underline-offset: 2px; }
.embed-preview-caption { margin-bottom: 12px; color: var(--ink-muted); font-size: 13px; text-align: center; }

@media (max-width: 960px) {
  .embed-grid { grid-template-columns: minmax(0, 1fr); gap: 32px; }
}
@media (max-width: 640px) {
  .embed-section { padding: 56px 0; }
  .embed-box { padding: 18px; }
  .embed-preview-frame { padding: 8px; }
}
@media print {
  .embed-section { display: none; }
}

/* 2. Embed view (inside someone else's iframe) */
html.nc-embed { scroll-padding-top: 0; }
html.nc-embed body { min-height: 0; }
html.nc-embed .skip-link,
html.nc-embed .site-header,
html.nc-embed .footer,
html.nc-embed .hero-copy,
html.nc-embed main > section:not(.hero):not(.report-section):not(.loose-section) { display: none !important; }
html.nc-embed .shell { width: min(100% - 32px, 1200px); }
html.nc-embed .hero { padding: 16px 0 24px; }
html.nc-embed .hero-grid { grid-template-columns: minmax(0, 1fr); gap: 0; }
html.nc-embed .upload-card { width: 100%; max-width: 620px; margin-inline: auto; }
html.nc-embed .report-section,
html.nc-embed .loose-section { padding: 32px 0; }
html.nc-embed .section-head { margin-bottom: 20px; }
html.nc-embed .section-head h2 { font-size: clamp(26px, 4vw, 38px); }
html.nc-embed section[id], html.nc-embed #upload { scroll-margin-top: 8px; }

.embed-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; background: var(--bg-elev); border-bottom: 1px solid var(--line); font-size: 13px; line-height: 1.3; }
.embed-bar a { display: inline-flex; align-items: center; gap: 8px; color: var(--ink); font-weight: 500; }
.embed-bar a:hover { color: var(--accent-deep); }
.embed-bar img { width: 22px; height: 22px; }
.embed-bar .embed-by { color: var(--ink-muted); font-weight: 400; white-space: nowrap; }
.embed-bar .embed-by:hover { color: var(--accent-deep); text-decoration: underline; text-underline-offset: 2px; }
@media print {
  .embed-bar { display: none; }
}
