/* =====================================================================
   Cafetito — Public styles
   ---------------------------------------------------------------------
   Applies to: public form, return-result page, public components.
   All rules read --cf-* tokens, so the same stylesheet works under any
   preset (Coffee / Neutral / Minimal / Site theme).
   The root element of every public artifact carries TWO classes:
     class="cafetito-public cafetito-preset-{slug}"
   CSS scope is fenced under `.cafetito-public` to avoid leaking into the
   host theme; the host theme cannot leak in either because we reset the
   essentials below.
   ===================================================================== */


/* ----- Reset (scoped, conservative) ----- */
.cafetito-public,
.cafetito-public * {
  box-sizing: border-box;
}
.cafetito-public {
  color: var(--cf-color-text);
  font-family: var(--cf-font-ui);
  font-size: var(--cf-font-size-base);
  line-height: var(--cf-line-height-normal);
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
}
.cafetito-public p,
.cafetito-public h1,
.cafetito-public h2,
.cafetito-public h3,
.cafetito-public h4 {
  margin: 0;
}
.cafetito-public button,
.cafetito-public input,
.cafetito-public textarea,
.cafetito-public select {
  font: inherit;
  color: inherit;
}
/* Inline links *inside text content*. The buttons and primary actions
   below re-declare their own color with matching specificity so they
   are not affected by this default. */
.cafetito-public a {
  color: var(--cf-color-primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}


/* =====================================================================
   FORM CARD
   ===================================================================== */
.cf-form {
  background: var(--cf-color-surface);
  border: 1px solid var(--cf-color-border);
  border-radius: var(--cf-radius-card);
  padding: var(--cf-space-6) var(--cf-space-6) var(--cf-space-6);
  max-width: var(--cf-form-max-width);
  box-shadow: var(--cf-shadow-sm);
}

.cf-form__title {
  font-family: var(--cf-font-display);
  font-size: var(--cf-font-size-xl);
  font-weight: var(--cf-font-weight-semibold);
  line-height: var(--cf-line-height-tight);
  letter-spacing: -0.005em;
  color: var(--cf-color-text);
  margin: 0 0 var(--cf-space-1);
}
.cf-form__sub {
  font-size: var(--cf-font-size-base);
  color: var(--cf-color-text-muted);
  line-height: var(--cf-line-height-normal);
  margin: 0 0 var(--cf-space-4);
}


/* =====================================================================
   FIELDS
   ===================================================================== */
.cf-field {
  display: flex;
  flex-direction: column;
  gap: var(--cf-space-2);
  margin-bottom: var(--cf-space-3);
}
.cf-field__label {
  font-size: var(--cf-font-size-sm);
  font-weight: var(--cf-font-weight-medium);
  color: var(--cf-color-text);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--cf-space-2);
}
.cf-field__optional {
  font-weight: var(--cf-font-weight-regular);
  font-size: var(--cf-font-size-xs);
  color: var(--cf-color-text-muted);
}
.cf-field__hint {
  font-size: var(--cf-font-size-xs);
  color: var(--cf-color-text-muted);
  line-height: var(--cf-line-height-normal);
}
.cf-field__error {
  font-size: var(--cf-font-size-xs);
  color: var(--cf-color-danger);
  line-height: var(--cf-line-height-normal);
  display: flex;
  align-items: flex-start;
  gap: var(--cf-space-1);
}

.cf-input,
.cf-textarea {
  width: 100%;
  min-height: var(--cf-touch-min);
  padding: 10px 12px;
  border: 1px solid var(--cf-color-border-strong);
  border-radius: var(--cf-radius-input);
  background: var(--cf-color-surface);
  color: var(--cf-color-text);
  font-family: var(--cf-font-ui);
  font-size: var(--cf-font-size-base);
  outline: none;
  transition: border-color var(--cf-duration-fast) var(--cf-easing-standard),
              box-shadow var(--cf-duration-fast) var(--cf-easing-standard);
}
.cf-input::placeholder,
.cf-textarea::placeholder {
  color: var(--cf-color-text-muted);
  opacity: 0.8;
}
.cf-input:hover,
.cf-textarea:hover {
  border-color: var(--cf-color-text-muted);
}
.cf-input:focus,
.cf-textarea:focus {
  border-color: var(--cf-color-primary);
  box-shadow: 0 0 0 var(--cf-focus-ring-width) var(--cf-color-focus-ring);
}
.cf-textarea {
  min-height: 88px;
  resize: vertical;
  line-height: var(--cf-line-height-normal);
}

/* Disabled */
.cf-input[disabled],
.cf-textarea[disabled] {
  background: var(--cf-color-surface-subtle);
  color: var(--cf-color-text-muted);
  cursor: not-allowed;
}

/* Error state on input */
.cf-field--error .cf-input,
.cf-field--error .cf-textarea {
  border-color: var(--cf-color-danger);
  box-shadow: 0 0 0 var(--cf-focus-ring-width) rgba(180, 35, 24, 0.18);
}


/* =====================================================================
   AMOUNT SELECTOR
   ===================================================================== */
.cf-amount {
  display: flex;
  flex-direction: column;
  gap: var(--cf-space-2);
}
.cf-amount__grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--cf-space-2);
}
.cf-amount-chip {
  min-height: var(--cf-touch-min);
  padding: 10px 12px;
  background: var(--cf-color-surface);
  border: 1px solid var(--cf-color-border-strong);
  border-radius: var(--cf-radius-chip);
  color: var(--cf-color-text);
  font-size: var(--cf-font-size-base);
  font-weight: var(--cf-font-weight-medium);
  cursor: pointer;
  text-align: center;
  transition: background var(--cf-duration-fast) var(--cf-easing-standard),
              border-color var(--cf-duration-fast) var(--cf-easing-standard),
              color var(--cf-duration-fast) var(--cf-easing-standard);
}
.cf-amount-chip:hover {
  border-color: var(--cf-color-primary);
}
.cf-amount-chip[aria-pressed="true"] {
  background: var(--cf-color-primary);
  color: var(--cf-color-primary-text);
  border-color: var(--cf-color-primary);
}
.cf-amount-chip:focus-visible {
  outline: none;
  box-shadow: 0 0 0 var(--cf-focus-ring-width) var(--cf-color-focus-ring);
  border-color: var(--cf-color-primary);
}

/* Free amount input row (with currency suffix) */
.cf-amount__free {
  position: relative;
  display: flex;
  align-items: center;
}
.cf-amount__free .cf-input {
  padding-right: 40px;
  font-feature-settings: "tnum" 1;
}
.cf-amount__free-suffix {
  position: absolute;
  right: 12px;
  font-size: var(--cf-font-size-base);
  color: var(--cf-color-text-muted);
  pointer-events: none;
}

/* Fixed amount display */
.cf-amount__fixed {
  padding: 14px 16px;
  background: var(--cf-color-surface-subtle);
  border: 1px solid var(--cf-color-border);
  border-radius: var(--cf-radius-input);
  font-size: var(--cf-font-size-lg);
  font-weight: var(--cf-font-weight-semibold);
  color: var(--cf-color-text);
  font-feature-settings: "tnum" 1;
}


/* =====================================================================
   METHOD PICKER
   ===================================================================== */
.cf-method {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--cf-space-2);
}
.cf-method__opt {
  display: flex;
  align-items: center;
  gap: var(--cf-space-2);
  min-height: var(--cf-touch-min);
  padding: 10px 12px;
  background: var(--cf-color-surface);
  border: 1px solid var(--cf-color-border-strong);
  border-radius: var(--cf-radius-input);
  font-size: var(--cf-font-size-base);
  color: var(--cf-color-text);
  cursor: pointer;
  position: relative;
  transition: border-color var(--cf-duration-fast) var(--cf-easing-standard),
              box-shadow var(--cf-duration-fast) var(--cf-easing-standard);
}
.cf-method__opt:hover {
  border-color: var(--cf-color-primary);
}
.cf-method__opt input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.cf-method__radio {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 1.5px solid var(--cf-color-border-strong);
  flex-shrink: 0;
  position: relative;
}
.cf-method__opt input[type="radio"]:checked + .cf-method__radio {
  border-color: var(--cf-color-primary);
}
.cf-method__opt input[type="radio"]:checked + .cf-method__radio::after {
  content: '';
  position: absolute;
  inset: 3px;
  border-radius: 999px;
  background: var(--cf-color-primary);
}
.cf-method__body {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1 1 auto;
}
.cf-method__label {
  display: inline-flex;
  align-items: center;
  gap: var(--cf-space-1);
  font-size: var(--cf-font-size-base);
  color: var(--cf-color-text);
  font-weight: var(--cf-font-weight-medium);
  line-height: 1.2;
}
.cf-method__sub {
  font-size: var(--cf-font-size-xs);
  color: var(--cf-color-text-muted);
  line-height: 1.2;
}
.cf-method__icon {
  flex-shrink: 0;
  color: var(--cf-color-text-muted);
}
.cf-method__opt:has(input[type="radio"]:checked) .cf-method__icon {
  color: var(--cf-color-primary);
}
.cf-method__opt:has(input[type="radio"]:checked) {
  border-color: var(--cf-color-primary);
  box-shadow: inset 0 0 0 1px var(--cf-color-primary);
}
.cf-method__opt:has(input[type="radio"]:focus-visible) {
  box-shadow: 0 0 0 var(--cf-focus-ring-width) var(--cf-color-focus-ring);
}


/* =====================================================================
   SUBMIT BUTTON
   The `.cafetito-public` prefix bumps specificity so it wins over the
   button reset above (`.cafetito-public button { color: inherit }`).
   ===================================================================== */
.cafetito-public .cf-submit {
  width: 100%;
  min-height: var(--cf-touch-min);
  padding: 14px 20px;
  background: var(--cf-color-primary);
  color: var(--cf-color-primary-text);
  border: 0;
  border-radius: var(--cf-radius-button);
  font-family: var(--cf-font-ui);
  font-size: var(--cf-font-size-md);
  font-weight: var(--cf-font-weight-semibold);
  letter-spacing: 0.01em;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--cf-space-2);
  margin-top: var(--cf-space-2);
  transition: background var(--cf-duration-fast) var(--cf-easing-standard);
}
.cafetito-public .cf-submit:hover { background: var(--cf-color-primary-hover); }
.cafetito-public .cf-submit:active { background: var(--cf-color-primary-active); }
.cafetito-public .cf-submit:focus-visible {
  outline: none;
  box-shadow: 0 0 0 var(--cf-focus-ring-width) var(--cf-color-focus-ring);
}
.cafetito-public .cf-submit[disabled],
.cafetito-public .cf-submit[aria-busy="true"] {
  cursor: not-allowed;
  opacity: 0.85;
}
.cafetito-public .cf-submit[aria-busy="true"] { pointer-events: none; }
.cf-submit__spinner {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  animation: cf-spin 0.7s linear infinite;
}
@keyframes cf-spin { to { transform: rotate(360deg); } }


/* =====================================================================
   COMPACT BUTTON (collapsed form)
   Prefixed for the same specificity reason as cf-submit.
   ===================================================================== */
.cafetito-public .cf-compact {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--cf-touch-min);
  padding: 12px 22px;
  background: var(--cf-color-primary);
  color: var(--cf-color-primary-text);
  border: 0;
  border-radius: var(--cf-radius-button);
  font-family: var(--cf-font-ui);
  font-size: var(--cf-font-size-md);
  font-weight: var(--cf-font-weight-semibold);
  letter-spacing: 0.01em;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--cf-duration-fast) var(--cf-easing-standard);
}
.cafetito-public .cf-compact:hover { background: var(--cf-color-primary-hover); }
.cafetito-public .cf-compact:active { background: var(--cf-color-primary-active); }
.cafetito-public .cf-compact:focus-visible {
  outline: none;
  box-shadow: 0 0 0 var(--cf-focus-ring-width) var(--cf-color-focus-ring);
}


/* =====================================================================
   TRUST FOOTER
   ===================================================================== */
.cf-trust {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--cf-space-2);
  margin-top: var(--cf-space-3);
  font-size: var(--cf-font-size-xs);
  color: var(--cf-color-text-muted);
}
.cf-trust svg {
  width: 12px;
  height: 14px;
  stroke: var(--cf-color-text-muted);
}


/* =====================================================================
   FORM-LEVEL ERROR / NOTICE
   ===================================================================== */
.cf-notice {
  padding: 12px 14px;
  border-radius: var(--cf-radius-input);
  font-size: var(--cf-font-size-base);
  line-height: var(--cf-line-height-normal);
  display: flex;
  align-items: flex-start;
  gap: var(--cf-space-2);
  margin-bottom: var(--cf-space-3);
}
.cf-notice--info {
  background: var(--cf-color-surface-subtle);
  color: var(--cf-color-text);
  border: 1px solid var(--cf-color-border);
}
.cf-notice--success {
  background: var(--cf-color-success-bg);
  color: var(--cf-color-success);
  border: 1px solid color-mix(in srgb, var(--cf-color-success) 30%, transparent);
}
.cf-notice--warning {
  background: var(--cf-color-warning-bg);
  color: var(--cf-color-warning);
  border: 1px solid color-mix(in srgb, var(--cf-color-warning) 30%, transparent);
}
.cf-notice--error {
  background: var(--cf-color-danger-bg);
  color: var(--cf-color-danger);
  border: 1px solid color-mix(in srgb, var(--cf-color-danger) 30%, transparent);
}
.cf-notice__icon { flex-shrink: 0; margin-top: 2px; }


/* =====================================================================
   RETURN RESULT
   ===================================================================== */
.cf-result {
  background: var(--cf-color-surface);
  border: 1px solid var(--cf-color-border);
  border-radius: var(--cf-radius-card);
  padding: var(--cf-space-8) var(--cf-space-6);
  max-width: var(--cf-form-max-width);
  box-shadow: var(--cf-shadow-sm);
  text-align: center;
}
.cf-result__icon {
  width: 56px;
  height: 56px;
  margin: 0 auto var(--cf-space-3);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.cf-result--success .cf-result__icon {
  background: var(--cf-color-success-bg);
  color: var(--cf-color-success);
}
.cf-result--cancelled .cf-result__icon {
  background: var(--cf-color-surface-subtle);
  color: var(--cf-color-text-muted);
}
.cf-result--rejected .cf-result__icon {
  background: var(--cf-color-danger-bg);
  color: var(--cf-color-danger);
}
.cf-result__icon svg { width: 28px; height: 28px; }

.cf-result__title {
  font-family: var(--cf-font-display);
  font-size: var(--cf-font-size-xl);
  font-weight: var(--cf-font-weight-semibold);
  line-height: var(--cf-line-height-tight);
  color: var(--cf-color-text);
  margin: 0 0 var(--cf-space-2);
}
.cf-result__body {
  font-size: var(--cf-font-size-base);
  color: var(--cf-color-text-muted);
  line-height: var(--cf-line-height-relaxed);
  margin: 0 auto var(--cf-space-6);
  max-width: 360px;
}
.cf-result__summary {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: var(--cf-space-2) var(--cf-space-4);
  text-align: left;
  background: var(--cf-color-surface-subtle);
  border: 1px solid var(--cf-color-border);
  border-radius: var(--cf-radius-input);
  padding: var(--cf-space-3) var(--cf-space-4);
  margin: 0 auto var(--cf-space-6);
  max-width: 360px;
  font-size: var(--cf-font-size-base);
}
.cf-result__summary dt {
  color: var(--cf-color-text-muted);
  font-size: var(--cf-font-size-sm);
}
.cf-result__summary dd {
  margin: 0;
  color: var(--cf-color-text);
  font-weight: var(--cf-font-weight-medium);
  font-feature-settings: "tnum" 1;
}
.cf-result__actions {
  display: flex;
  gap: var(--cf-space-3);
  justify-content: center;
  flex-wrap: wrap;
}
.cafetito-public .cf-result__action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--cf-touch-min);
  padding: 12px 20px;
  border-radius: var(--cf-radius-button);
  font-size: var(--cf-font-size-base);
  font-weight: var(--cf-font-weight-medium);
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--cf-duration-fast) var(--cf-easing-standard);
}
.cafetito-public .cf-result__action--primary {
  background: var(--cf-color-primary);
  color: var(--cf-color-primary-text);
}
.cafetito-public .cf-result__action--primary:hover { background: var(--cf-color-primary-hover); }
.cafetito-public .cf-result__action--secondary {
  background: transparent;
  color: var(--cf-color-text);
  border-color: var(--cf-color-border-strong);
}
.cafetito-public .cf-result__action--secondary:hover {
  border-color: var(--cf-color-text);
}
.cafetito-public .cf-result__action:focus-visible {
  outline: none;
  box-shadow: 0 0 0 var(--cf-focus-ring-width) var(--cf-color-focus-ring);
}
