/* ========================================
   STAGEPLOT — STANDALONE PAGE CHROME ONLY
   The editor itself (palette · canvas · inspector · elements) is styled by
   css/stageplot-editor.css, the SINGLE shared editor skin loaded FIRST on this
   page and inside the dashboard embed. This file styles only the standalone
   page shell: top login strip, toolbar, title input, primary/secondary CTAs,
   the mobile gate, the email/share modals, and the toast.

   Design language matches the dashboard editor (stageplot-editor.css --spe-*):
   white panels, #f7f7f5 surfaces, #fbd033 gold accent, 6px radius, dark ink.
   Tokens are scoped to `body` (NOT :root) so they can never collide with the
   editor's --spe-* set or anything else if this sheet is ever loaded elsewhere.
   ======================================== */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  /* Page chrome tokens — mirror stageplot-editor.css values. */
  --sp-bg: #ffffff;
  --sp-panel: #f7f7f5;
  --sp-border: #e3e2de;
  --sp-ink: #1a1a1a;
  --sp-dim: #6b6b6b;
  --sp-accent: #fbd033;
  --sp-accent-hover: #ffe066;
  --sp-danger: #e23b3b;
  --sp-radius: 6px;
  --sp-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  font-family: var(--sp-font);
  background: var(--sp-bg);
  color: var(--sp-ink);
  overflow: hidden;
  height: 100vh;
}

/* SEO content — visible to crawlers, hidden visually. Keep verbatim. */
.seo-content {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ========================================
   VIEWPORT GATE → conversion surface (<900px)
   ======================================== */

.viewport-gate {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: var(--sp-bg);
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px 24px;
}

.viewport-gate-content {
  max-width: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.viewport-gate-logo {
  height: 28px;
  width: auto;
}

.viewport-gate h2 {
  font-size: 1.35rem;
  color: var(--sp-ink);
}

.viewport-gate p {
  font-size: 0.95rem;
  color: var(--sp-dim);
  line-height: 1.5;
}

/* Lead-capture form on the gate. */
.viewport-gate-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  margin-top: 4px;
}

.viewport-gate-form input[type="email"] {
  width: 100%;
  padding: 12px 14px;
  font-size: 1rem;
  border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius);
  background: var(--sp-bg);
  color: var(--sp-ink);
}

.viewport-gate-form input[type="email"]:focus {
  outline: none;
  border-color: var(--sp-accent);
}

.viewport-gate-submit {
  padding: 12px 18px;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: var(--sp-radius);
  background: var(--sp-accent);
  color: var(--sp-ink);
  cursor: pointer;
}

.viewport-gate-submit:hover { background: var(--sp-accent-hover); }
.viewport-gate-submit:disabled { opacity: 0.6; cursor: not-allowed; }

.viewport-gate-error {
  color: var(--sp-danger);
  font-size: 0.85rem;
  min-height: 1.1em;
}

.viewport-gate-cta {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--sp-ink);
  text-decoration: none;
  border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius);
  padding: 11px 18px;
  transition: border-color 0.15s ease;
}

.viewport-gate-cta:hover { border-color: var(--sp-accent); }

.viewport-gate-divider {
  font-size: 0.8rem;
  color: var(--sp-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.viewport-gate-success p { color: var(--sp-ink); }
.viewport-gate-success .viewport-gate-url {
  font-weight: 600;
  color: var(--sp-ink);
  word-break: break-all;
}

@media (max-width: 899px) {
  .viewport-gate { display: flex; }
  #stageplot-app { display: none; }
}

/* ========================================
   APP LAYOUT
   ======================================== */

#stageplot-app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* Logged-out top login strip. */
.sp-login-strip {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
  padding: 6px 24px;
  background: var(--sp-panel);
  border-bottom: 1px solid var(--sp-border);
  font-size: 13px;
  color: var(--sp-dim);
}
.sp-login-strip a {
  color: var(--sp-ink);
  font-weight: 600;
  text-decoration: none;
}
.sp-login-strip a:hover { text-decoration: underline; }

/* Toolbar — matches the dashboard editor top bar. */
.stageplot-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
  background: var(--sp-bg);
  border-bottom: 1px solid var(--sp-border);
}

.toolbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-logo {
  height: 22px;
  width: auto;
  flex-shrink: 0;
}

.sp-title-input {
  font-size: 16px;
  font-weight: 600;
  color: var(--sp-ink);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--sp-radius);
  padding: 5px 8px;
  min-width: 180px;
  font-family: var(--sp-font);
}
.sp-title-input::placeholder { color: var(--sp-dim); font-weight: 500; }
.sp-title-input:hover { border-color: var(--sp-border); }
.sp-title-input:focus {
  outline: none;
  border-color: var(--sp-accent);
  background: var(--sp-bg);
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Undo / redo / reset icon buttons. */
.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  background: var(--sp-bg);
  border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius);
  color: var(--sp-ink);
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.btn-icon:hover:not(:disabled) {
  border-color: var(--sp-accent);
}
.btn-icon:disabled {
  opacity: 0.35;
  cursor: default;
}
.btn-icon svg { display: block; }

/* "Turn Plot Into Website" — secondary CTA. */
.toolbar-cta {
  font-family: var(--sp-font);
  font-size: 14px;
  font-weight: 600;
  padding: 8px 16px;
  background: var(--sp-bg);
  color: var(--sp-ink);
  border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius);
  cursor: pointer;
  text-decoration: none;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  transition: border-color 0.15s ease;
}
.toolbar-cta:hover { border-color: var(--sp-accent); }

/* Download PDF — primary CTA (gold). */
#btn-download {
  font-family: var(--sp-font);
  font-size: 14px;
  font-weight: 600;
  padding: 8px 20px;
  background: var(--sp-accent);
  color: var(--sp-ink);
  border: 1px solid var(--sp-accent);
  border-radius: var(--sp-radius);
  cursor: pointer;
  transition: background 0.15s ease;
}
#btn-download:hover { background: var(--sp-accent-hover); }
#btn-download:active { transform: scale(0.98); }
#btn-download:disabled { opacity: 0.7; cursor: wait; }
#btn-download.btn-loading { pointer-events: none; }

/* Standalone mount fills the height below the strip + toolbar. */
#sp-mount {
  flex: 1;
  display: flex;
  min-height: 0;
}
#sp-mount .stageplot-main {
  flex: 1;
  min-height: 0;
}

/* ========================================
   EMAIL CAPTURE MODAL — bottom sheet (light)
   ======================================== */

.email-modal {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  margin: 32px 0 0 0;
  padding: 0;
  border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius) var(--sp-radius) 0 0;
  max-width: 100%;
  width: 100%;
  max-height: 90vh;
  background: var(--sp-bg);
  color: var(--sp-ink);
  z-index: 9999;
}

.email-modal::backdrop {
  background: rgba(0, 0, 0, 0.45);
}

.email-modal[open] { animation: spSlideUp 0.3s ease-out; }

@keyframes spSlideUp {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

.email-modal .modal-content {
  position: relative;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.email-modal .modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: transparent;
  border: none;
  color: var(--sp-dim);
  font-size: 24px;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
}
.email-modal .modal-close:hover { color: var(--sp-ink); }

.email-modal .modal-headline {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
  padding-right: 32px;
  color: var(--sp-ink);
}

.email-modal .modal-subtext {
  color: var(--sp-dim);
  margin: 0;
  font-size: 0.9rem;
}

.email-modal .modal-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.email-modal .modal-field input {
  padding: 12px 16px;
  font-size: 1rem;
  border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius);
  background: var(--sp-bg);
  color: var(--sp-ink);
}
.email-modal .modal-field input:focus { outline: none; border-color: var(--sp-accent); }
.email-modal .modal-field input::placeholder { color: var(--sp-dim); }

.email-modal .modal-error {
  color: var(--sp-danger);
  font-size: 0.85rem;
  min-height: 1.2em;
}

.email-modal .modal-progress {
  color: var(--sp-dim);
  font-size: 0.9rem;
  min-height: 1.4em;
  text-align: center;
}

.email-modal .modal-submit {
  padding: 14px 24px;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: var(--sp-radius);
  background: var(--sp-accent);
  color: var(--sp-ink);
  cursor: pointer;
  transition: background 0.2s;
}
.email-modal .modal-submit:hover { background: var(--sp-accent-hover); }
.email-modal .modal-submit:disabled { opacity: 0.55; cursor: not-allowed; }

.email-modal .modal-cta-banner {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  background: var(--sp-panel);
  border-radius: var(--sp-radius);
  border: 1px solid var(--sp-border);
  text-align: center;
}
.email-modal .modal-cta-text { font-size: 0.8rem; color: var(--sp-dim); }
.email-modal .modal-cta-link {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--sp-ink);
  text-decoration: none;
}
.email-modal .modal-cta-link:hover { text-decoration: underline; }

@media (min-width: 600px) {
  .email-modal {
    left: 50%;
    transform: translateX(-50%);
    max-width: 400px;
    border-radius: var(--sp-radius);
  }
  .email-modal[open] { animation: spSlideUpDesktop 0.3s ease-out; }
  @keyframes spSlideUpDesktop {
    from { transform: translateX(-50%) translateY(100%); opacity: 0; }
    to   { transform: translateX(-50%) translateY(0); opacity: 1; }
  }
}

/* ========================================
   SHARE LINK MODAL — bottom sheet (light, button hidden but kept for parity)
   ======================================== */

.share-modal {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  margin: 0;
  padding: 0;
  border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius) var(--sp-radius) 0 0;
  max-width: 100%;
  width: 100%;
  max-height: 90vh;
  background: var(--sp-bg);
  color: var(--sp-ink);
  z-index: 9999;
}
.share-modal::backdrop { background: rgba(0, 0, 0, 0.45); }
.share-modal[open] { animation: spSlideUp 0.3s ease-out; }

.share-modal .modal-content {
  position: relative;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.share-modal .modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: transparent;
  border: none;
  color: var(--sp-dim);
  font-size: 24px;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
}
.share-modal .modal-close:hover { color: var(--sp-ink); }
.share-modal .modal-headline {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
  padding-right: 32px;
  color: var(--sp-ink);
}
.share-modal .modal-subtext { color: var(--sp-dim); margin: 0; font-size: 0.9rem; }

.share-url-field { display: flex; gap: 8px; align-items: stretch; }
.share-url-input {
  flex: 1;
  padding: 12px 16px;
  font-size: 0.9rem;
  font-family: monospace;
  border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius);
  background: var(--sp-panel);
  color: var(--sp-ink);
  min-width: 0;
}
.share-url-input:focus { outline: none; border-color: var(--sp-accent); }
.share-copy-btn {
  padding: 12px 20px;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: var(--sp-radius);
  background: var(--sp-accent);
  color: var(--sp-ink);
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}
.share-copy-btn:hover { background: var(--sp-accent-hover); }
.share-copy-btn.copied { background: #22c55e; color: #fff; }

@media (min-width: 600px) {
  .share-modal {
    left: 50%;
    transform: translateX(-50%);
    max-width: 480px;
    border-radius: var(--sp-radius) var(--sp-radius) 0 0;
  }
  .share-modal[open] { animation: spSlideUpDesktop 0.3s ease-out; }
}

/* ========================================
   TOAST (shared js/shared/toast.js contract)
   ======================================== */

.sp-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--sp-ink);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--sp-radius);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.18);
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 100000;
  pointer-events: none;
}
.sp-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.sp-toast.error { background: var(--sp-danger); }
