/* ---------------------------------------------------------------------------
 * forms.css — the site-wide FORM SYSTEM and ORDER SUMMARY.
 *
 * Loaded globally from partials/site-head.ejs, after base.css/components.css,
 * because checkout, contact, sign-in, sign-up, password reset and the account
 * pages must all look and behave identically. Extend it here; never restyle a
 * control inside a page sheet.
 *
 * Token references only — no literal colours, sizes or spacings. The one
 * exception is #fff on the accent gradient (tick marks, gradient buttons),
 * matching the existing .cta-band convention: the palette has no pure-white
 * token and white is what the gradient requires.
 * ------------------------------------------------------------------------- */

/* ===========================================================================
   LAYOUT
   =========================================================================== */
.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-5);
}
@media (min-width: 640px) {
  .form-grid--2 { grid-template-columns: 1fr 1fr; }
  .form-grid__full { grid-column: 1 / -1; }
}

.fieldset {
  border: 0;
  padding: 0;
  margin: 0 0 var(--space-8);
  min-width: 0;
}
.fieldset__legend {
  font-family: var(--font-display);
  font-size: var(--h3-size);
  font-weight: var(--h3-weight);
  letter-spacing: var(--h3-tracking);
  color: var(--text-primary);
  padding: 0;
  margin-bottom: var(--space-5);
}

/* ===========================================================================
   FIELDS
   =========================================================================== */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
}

.field__label {
  font-family: var(--font-display);
  font-size: var(--body-sm-size);
  font-weight: 600;
  color: var(--text-primary);
}
.field__req { color: var(--accent-pink); }
.field__hint {
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-muted);
}

/* One control surface for every input type. */
.input,
.select,
.textarea {
  width: 100%;
  min-width: 0;
  background: var(--surface-1);
  color: var(--text-primary);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-body);
  font-size: var(--body-size);
  line-height: 1.4;
  transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}
.input::placeholder,
.textarea::placeholder { color: var(--text-muted); }

.input:hover,
.select:hover,
.textarea:hover { border-color: var(--border-hairline-hover); }

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--accent-purple);
  box-shadow: var(--focus-ring);
  background: var(--surface-2);
}

.input:disabled,
.select:disabled,
.textarea:disabled { opacity: .55; cursor: not-allowed; }

.textarea { min-height: 120px; resize: vertical; }

.select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: var(--space-8);
  cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
                    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}
.select option { background: var(--surface-2); color: var(--text-primary); }

/* Field-level error. Put .field--error on the wrapper AND aria-invalid on the
   control, then render .field__error beneath it. */
.field--error .input,
.field--error .select,
.field--error .textarea,
.input[aria-invalid="true"],
.select[aria-invalid="true"],
.textarea[aria-invalid="true"] {
  border-color: var(--error-border);
  background: var(--error-tint);
}
.field--error .input:focus,
.field--error .select:focus,
.field--error .textarea:focus,
.input[aria-invalid="true"]:focus,
.select[aria-invalid="true"]:focus {
  border-color: var(--error);
  box-shadow: 0 0 0 3px var(--error-tint);
}
.field__error {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  font-size: 13px;
  line-height: 1.45;
  color: var(--error);
}

/* Dial-code select + local number on one row. */
.field-phone {
  display: grid;
  grid-template-columns: minmax(104px, 36%) 1fr;
  gap: var(--space-2);
  min-width: 0;
}

/* ===========================================================================
   CHECKBOX
   =========================================================================== */
.checkbox {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  cursor: pointer;
  font-size: var(--body-sm-size);
  line-height: 1.5;
  color: var(--text-secondary);
}
.checkbox__box {
  appearance: none;
  -webkit-appearance: none;
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin: 0;
  border: 1px solid var(--border-hairline-hover);
  border-radius: var(--radius-sm);
  background: var(--surface-1);
  cursor: pointer;
  position: relative;
  transition: background .15s ease, border-color .15s ease;
}
.checkbox__box:hover { border-color: var(--accent-purple); }
.checkbox__box:checked { background: var(--gradient-accent); border-color: transparent; }
.checkbox__box:checked::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 2px;
  width: 5px;
  height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.checkbox__box:focus-visible { box-shadow: var(--focus-ring); outline: none; }
.field--error .checkbox__box { border-color: var(--error-border); background: var(--error-tint); }

/* ===========================================================================
   RADIO CARDS — one-of-N choices (payment method, and anything similar later)
   =========================================================================== */
.radio-cards { display: flex; flex-direction: column; gap: var(--space-3); }

.radio-card {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  padding: var(--space-5);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-lg);
  background: var(--surface-1);
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.radio-card:hover { border-color: var(--border-hairline-hover); background: var(--surface-2); }

.radio-card__input {
  appearance: none;
  -webkit-appearance: none;
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin-top: 2px;
  border: 1px solid var(--border-hairline-hover);
  border-radius: var(--radius-full);
  background: var(--surface-1);
  cursor: pointer;
  position: relative;
  transition: border-color .15s ease;
}
.radio-card__input:checked { border-color: var(--accent-purple); }
.radio-card__input:checked::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: var(--radius-full);
  background: var(--gradient-accent);
}
.radio-card__input:focus-visible { box-shadow: var(--focus-ring); outline: none; }

/* :has() lifts the whole card on selection. Browsers without :has() simply keep
   the default border — the radio dot still shows the state, so nothing breaks. */
.radio-card:has(.radio-card__input:checked) {
  border-color: var(--accent-purple);
  background: var(--surface-2);
  box-shadow: var(--elev-1), var(--elev-1-highlight);
}

.radio-card__body { flex: 1; min-width: 0; }
.radio-card__head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}
.radio-card__title {
  font-family: var(--font-display);
  font-size: var(--body-size);
  font-weight: 600;
  color: var(--text-primary);
}
.radio-card__blurb {
  font-size: var(--body-sm-size);
  line-height: 1.5;
  font-weight: 300;
  color: var(--text-secondary);
  margin: 0;
}
.radio-card__price {
  margin-top: var(--space-3);
  font-family: var(--font-display);
  font-size: var(--body-size);
  font-weight: 700;
  color: var(--text-primary);
}
.radio-card__price small {
  display: block;
  font-family: var(--font-body);
  font-weight: 400;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Unavailable option (a gateway that is not live yet). Deliberately still
   visible and readable: the customer should see the option is coming rather
   than have it silently disappear. */
.radio-card--disabled { cursor: not-allowed; opacity: .62; background: transparent; border-style: dashed; }
.radio-card--disabled:hover { border-color: var(--border-hairline); background: transparent; }
.radio-card--disabled .radio-card__input { cursor: not-allowed; }

.badge--muted { background: var(--surface-3); color: var(--text-muted); }
.badge--save {
  background: var(--success-tint);
  color: var(--success);
  border-color: var(--success-border);
}

/* ===========================================================================
   ORDER SUMMARY — shared by cart, checkout and the payment pages
   =========================================================================== */
.summary {
  background: var(--surface-2);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--elev-1), var(--elev-1-highlight);
}
.summary__title {
  font-family: var(--font-display);
  font-size: var(--h3-size);
  font-weight: var(--h3-weight);
  letter-spacing: var(--h3-tracking);
  margin: 0 0 var(--space-5);
}
.summary__rows { margin: 0; }
.summary__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
  padding-block: var(--space-3);
  font-size: var(--body-sm-size);
  color: var(--text-secondary);
}
.summary__row dt { min-width: 0; }
.summary__row dd { margin: 0; text-align: right; white-space: nowrap; color: var(--text-primary); }
.summary__row--discount dd { color: var(--success); }
.summary__row--sub { font-size: 13px; color: var(--text-muted); padding-block: var(--space-1); }
.summary__row--sub dd { color: var(--text-muted); }

.summary__total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-hairline-hover);
}
.summary__total dt {
  font-family: var(--font-display);
  font-size: var(--body-lg-size);
  font-weight: 600;
  color: var(--text-primary);
}
.summary__total dd {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(26px, 4vw, 32px);
  font-weight: 700;
  line-height: 1.1;
  color: var(--text-primary);
  white-space: nowrap;
}
.summary__note {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-muted);
  margin: var(--space-4) 0 0;
}
.summary__actions { margin-top: var(--space-5); display: flex; flex-direction: column; gap: var(--space-3); }
