/* ============================================================
   Early Access Module — Reusable styles
   ------------------------------------------------------------
   Depends on: tokens.css (design tokens, .btn, .input, .modal-overlay)
   No page-specific selectors. Safe to drop into any product page.
   Theming: follows [data-theme] tokens automatically.
   ============================================================ */

/* ===== Trigger buttons =====
   Use the host page's .btn classes; we only add a small badge dot
   for the "beta" affordance. Triggers carry data-ea-trigger + data-ea-location.
*/
/* Make sure HTML's built-in [hidden] actually wins over utility .btn display. */
[hidden] { display: none !important; }

.ea-trigger {
  position: relative;
}
.ea-trigger .ea-beta-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px var(--success-bg);
  margin-right: 8px;
  vertical-align: middle;
}

/* ===== Modal overlay (reuses .modal-overlay from tokens) ===== */
.ea-modal {
  max-width: 480px;
  width: min(92vw, 480px);
  max-height: 92vh;
  overflow-y: auto;
  /* Local background so the modal looks consistent even on pages that
     override .modal. Falls back to surface token. */
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-xl);
  transform: translateY(16px) scale(0.97);
  transition: transform var(--duration-normal) var(--ease-out);
}
.modal-overlay.active .ea-modal {
  transform: translateY(0) scale(1);
}

/* ===== Modal header ===== */
.ea-modal-head {
  position: relative;
  padding: var(--space-32) var(--space-32) var(--space-16);
  text-align: left;
}
.ea-modal-close {
  position: absolute;
  top: var(--space-16);
  right: var(--space-16);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-tertiary);
  background: transparent;
  transition: background var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out);
}
.ea-modal-close:hover {
  background: var(--bg-elevated);
  color: var(--fg);
}
.ea-modal-close:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.ea-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
}
.ea-eyebrow::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px var(--success-bg);
}
.ea-title {
  font-family: var(--font-display, var(--font-sans));
  font-size: 26px;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.3px;
  color: var(--fg);
  margin: 0 0 8px;
}
.ea-desc {
  font-size: 14px;
  line-height: 1.5;
  color: var(--fg-secondary);
  margin: 0;
  max-width: 40ch;
}

/* ===== Modal body / form ===== */
.ea-modal-body {
  padding: var(--space-8) var(--space-32) var(--space-32);
}
.ea-field {
  margin-bottom: var(--space-16);
}
.ea-field:last-child {
  margin-bottom: 0;
}
.ea-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 6px;
}
.ea-label .ea-opt {
  font-weight: 400;
  color: var(--fg-tertiary);
  margin-left: 4px;
}
.ea-input,
.ea-select,
.ea-textarea {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border-strong);
  background: var(--surface);
  color: var(--fg);
  font-size: 15px;
  line-height: 1.4;
  font-family: inherit;
  transition: border-color var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out),
              background var(--duration-normal) var(--ease-out);
}
.ea-input::placeholder,
.ea-textarea::placeholder {
  color: var(--fg-tertiary);
}
.ea-input:focus,
.ea-select:focus,
.ea-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}
.ea-input[aria-invalid="true"] {
  border-color: var(--error);
  box-shadow: 0 0 0 3px var(--error-bg);
}
.ea-textarea {
  min-height: 72px;
  resize: vertical;
}
.ea-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2386868b' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

/* Inline error message */
.ea-error {
  display: none;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-size: 13px;
  color: var(--error);
  line-height: 1.4;
}
.ea-error[data-show="true"] {
  display: flex;
}
.ea-error svg {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
}

/* Submit button row */
.ea-submit-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: var(--space-20);
}
.ea-submit {
  width: 100%;
  justify-content: center;
}
.ea-submit[disabled],
.ea-submit[aria-busy="true"] {
  opacity: 0.7;
  cursor: not-allowed;
  pointer-events: none;
}
/* v22: "locked" state — button disabled because Turnstile hasn't produced
   a token yet (or the email was already registered). Stronger visual cue
   than the plain disabled style so the user knows to look at the widget. */
.ea-submit[data-ea-locked] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}
.ea-submit .ea-spinner {
  display: none;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: ea-spin 0.7s linear infinite;
}
.ea-submit[aria-busy="true"] .ea-spinner {
  display: inline-block;
}
.ea-submit[aria-busy="true"] .ea-submit-label {
  opacity: 0.85;
}
@keyframes ea-spin {
  to { transform: rotate(360deg); }
}

/* ===== Success / duplicate state ===== */
.ea-state {
  text-align: center;
  padding: var(--space-20) var(--space-32) var(--space-32);
}
.ea-check {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--success-bg);
  color: var(--success);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--space-16);
  animation: ea-pop 0.4s var(--ease-out) both;
}
.ea-check svg {
  width: 28px;
  height: 28px;
}
@keyframes ea-pop {
  0%   { transform: scale(0.6); opacity: 0; }
  60%  { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); }
}
.ea-state-title {
  font-family: var(--font-display, var(--font-sans));
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.3px;
  color: var(--fg);
  margin: 0 0 8px;
}
.ea-state-desc {
  font-size: 14px;
  line-height: 1.5;
  color: var(--fg-secondary);
  margin: 0 0 6px;
}
.ea-state-extra {
  font-size: 13px;
  line-height: 1.5;
  color: var(--fg-tertiary);
  margin: 0 0 var(--space-20);
}
.ea-state-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
}
.ea-state-actions .btn {
  width: 100%;
  justify-content: center;
}

/* ===== Beta announcement strip (optional, used in hero) ===== */
.ea-beta-strip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 8px;
  border-radius: var(--radius-pill);
  background: var(--success-bg);
  color: var(--success);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.ea-beta-strip .ea-beta-dot {
  margin-right: 0;
}
.ea-beta-strip button,
.ea-beta-strip a {
  color: inherit;
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid currentColor;
  padding-bottom: 1px;
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
  .ea-modal-head,
  .ea-modal-body,
  .ea-state {
    padding-left: var(--space-24);
    padding-right: var(--space-24);
  }
  .ea-title { font-size: 22px; }
  .ea-state-title { font-size: 21px; }
}

/* ===== Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
  .ea-modal,
  .modal-overlay.active .ea-modal,
  .ea-check,
  .ea-submit .ea-spinner {
    transition: none;
    animation: none;
  }
  .ea-spinner { animation-duration: 0s !important; }
}
