/* ==========================================================================
   Trial form and Stripe checkout modal.

   Uses only the design tokens from style.css. Layout is written with logical
   properties (inline-size, margin-inline, text-align: start) so the Arabic RTL
   and English LTR versions share one implementation.
   ========================================================================== */

/* ------------------------------------------------------------ utility ---- */

.sr-only {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* --------------------------------------------------------- trial form ---- */

.trial-form {
  inline-size: 100%;
  max-inline-size: 560px;
}

/* The hero keeps the form and the note stacked in normal flow. */
.hero-cta .trial-form {
  inline-size: 100%;
}

.hero-cta .hero-note {
  margin-block-start: 12px;
}

.trial-form__row {
  display: flex;
  align-items: stretch;
  gap: 8px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.trial-form__row:focus-within {
  border-color: var(--brand);
  box-shadow: var(--ring);
}

.api-input {
  flex: 1 1 auto;
  min-inline-size: 0;
  padding: 12px 18px;
  background: transparent;
  border: 0;
  outline: none;
  color: var(--text);
  font: inherit;
  font-size: 16px;
  text-align: start;
}

.api-input::placeholder {
  color: var(--text-dim);
}

.api-input:-webkit-autofill {
  -webkit-text-fill-color: var(--text);
  transition: background-color 9999s ease-out;
}

.trial-form .btn {
  flex: 0 0 auto;
}

.trial-form.is-busy .trial-form__row {
  opacity: 0.85;
}

.trial-form .btn[disabled] {
  cursor: progress;
  opacity: 0.7;
}

.form-msg {
  margin: 10px 0 0;
  font-size: 14px;
  line-height: 1.6;
}

.form-msg:empty {
  display: none;
}

.form-msg--ok {
  color: var(--trust);
}

.form-msg--error {
  color: var(--danger);
}

.form-link {
  color: var(--brand);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.form-msg--info {
  color: var(--text-soft);
}

/* An inline note shown only when JavaScript is unavailable. */
.no-js-note {
  display: none;
}

html:not(.js) .no-js-note {
  display: block;
}

html:not(.js) .trial-form__row {
  display: none;
}

/* -------------------------------------------------------------- modal ---- */

.modal[hidden] {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 18px;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.74);
  backdrop-filter: blur(3px);
}

.modal__panel {
  position: relative;
  z-index: 1;
  inline-size: min(460px, 100%);
  max-block-size: calc(100vh - 36px);
  overflow-y: auto;
  padding: 26px;
  background: var(--bg-soft);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
}

.modal__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-block-end: 6px;
}

.modal__title {
  margin: 0;
  font-size: 20px;
  line-height: 1.35;
}

.modal__plan {
  color: var(--brand);
}

.modal__sub {
  margin: 0 0 18px;
  color: var(--text-soft);
  font-size: 14.5px;
  line-height: 1.6;
}

.modal__close {
  flex: 0 0 auto;
  inline-size: 36px;
  block-size: 36px;
  display: grid;
  place-items: center;
  border-radius: var(--r-pill);
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--text-soft);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.modal__close:hover {
  color: var(--text);
  border-color: var(--brand);
}

.modal__fields {
  display: grid;
  gap: 12px;
}

.modal__fields .api-input {
  inline-size: 100%;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
}

.modal__fields .api-input:focus {
  border-color: var(--brand);
  box-shadow: var(--ring);
}

.modal__amount b {
  color: var(--text);
  font-size: 18px;
}

.modal__note {
  margin: 14px 0 0;
  color: var(--text-dim);
  font-size: 12.5px;
  line-height: 1.6;
}

html.has-modal,
html.has-modal body {
  overflow: hidden;
}

/* ------------------------------------------------------------ mobile ---- */

@media (max-width: 640px) {
  .trial-form__row {
    flex-direction: column;
    border-radius: var(--r-lg);
    padding: 8px;
  }

  .trial-form .btn {
    inline-size: 100%;
  }

  .modal__panel {
    padding: 20px;
  }
}

/* -------------------------------------------------------- reduced motion */

@media (prefers-reduced-motion: reduce) {
  .modal__backdrop {
    backdrop-filter: none;
  }
}
