/**
 * @file
 * Checkout styles for the Barjo theme.
 *
 * The theme already styles fieldset+legend for the checkout flow (grey bar +
 * blue text, see skin/substyle.css). This file applies the same pattern to
 * panes that don't use fieldsets (agree_terms, order_fields:checkout) and
 * styles the payment-method radios as clickable cards.
 *
 * Selectors prefer data-drupal-selector attributes and stable classes so the
 * styles survive Commerce's AJAX form rebuilds (Drupal can append random
 * suffixes to element IDs when re-rendering parts of a form).
 */

/* =============================================================================
   Synthetic grey-bar header — reusable visual for non-fieldset panes
   ============================================================================= */

/*
 * Use the same background/color/size as
 * .commerce-checkout-flow-multistep-default legend
 * so all section headers look identical.
 */

/* =============================================================================
   Payment information pane — unwrap outer fieldset, render Billing & Payment
   as two sibling cards
   ============================================================================= */

.checkout-pane-payment-information {
  outline: none;
  margin: 0 0 25px;
  padding: 0;
}

/* Outer "Billing information" legend is replaced by the inner cards' headers. */
.checkout-pane-payment-information > legend {
  display: none;
}

.checkout-pane-payment-information > .fieldset-wrapper {
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 25px;
}

/* =============================================================================
   Billing information sub-form card (synthetic header)
   ============================================================================= */

/*
 * The billing area sits at one of two paths depending on whether the selected
 * gateway uses an existing saved card (no wrapper) or a new payment method
 * (wrapped in add_payment_method). Match both as the "Billing" card.
 */
.checkout-pane-payment-information > .fieldset-wrapper > [data-drupal-selector="edit-payment-information-billing-information"],
.checkout-pane-payment-information > .fieldset-wrapper > [data-drupal-selector="edit-payment-information-add-payment-method"] {
  order: 1;
  background: #fff;
  outline: 1px solid #eeeff2;
  margin: 0;
  padding: 15px;
}

.checkout-pane-payment-information > .fieldset-wrapper > [data-drupal-selector="edit-payment-information-billing-information"]::before,
.checkout-pane-payment-information > .fieldset-wrapper > [data-drupal-selector="edit-payment-information-add-payment-method"]::before {
  content: "Billing information";
  display: block;
  font-size: 20px;
  color: #000 !important;
  background: #f9f7f3 !important;
  padding: 8px 15px;
  margin: -15px -15px 15px;
  font-weight: 500;
}

/* Match real fieldset legends to the same colour so all section headers
   look identical. */
form.commerce-checkout-flow-multistep-default legend {
  background: #f9f7f3 !important;
}

/* =============================================================================
   Payment method inner fieldset — sits below Billing
   ============================================================================= */

.checkout-pane-payment-information [data-drupal-selector="edit-payment-information-payment-method"] {
  order: 2;
  margin: 0;
}

/* =============================================================================
   Payment method radios — clickable cards
   ============================================================================= */

/* Visually hide the radio circle but keep it accessible to AT and keyboard. */
.checkout-pane-payment-information input.payment-method--new[type="radio"] {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  border: 0;
}

.checkout-pane-payment-information .form-item-payment-information-payment-method {
  display: block;
  margin: 0 0 0.625em;
  padding: 0.875em 3em 0.875em 1.25em;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.checkout-pane-payment-information .form-item-payment-information-payment-method:last-child {
  margin-bottom: 0;
}

.checkout-pane-payment-information .form-item-payment-information-payment-method:hover {
  border-color: #888;
}

/* Selected card — orange border + 1px outer ring (no layout shift). */
.checkout-pane-payment-information .form-item-payment-information-payment-method:has(input:checked) {
  border-color: #ff9f1c;
  box-shadow: 0 0 0 1px #ff9f1c;
}

/* Green check on the right of the selected card. */
.checkout-pane-payment-information .form-item-payment-information-payment-method:has(input:checked)::after {
  content: "\2713";
  position: absolute;
  right: 1.25em;
  top: 50%;
  transform: translateY(-50%);
  color: #5cb85c;
  font-weight: bold;
  font-size: 1.5em;
  line-height: 1;
}

.checkout-pane-payment-information .form-item-payment-information-payment-method label.option {
  display: flex;
  align-items: center;
  gap: 0.75em;
  margin: 0;
  font-weight: 500;
  color: #333;
  cursor: pointer;
}

/* Constrain any embedded gateway logos. */
.checkout-pane-payment-information .form-item-payment-information-payment-method label.option img {
  max-height: 24px;
  width: auto;
  flex-shrink: 0;
}

/*
 * After the AJAX rebuild (triggered by switching payment method) Drupal
 * appends a random suffix to each radio's id AND data-drupal-selector,
 * so target the radio by its stable `value` attribute instead.
 */

/* Hide PayPal's wide "Acceptance" image — we replace it with a cleaner mark. */
.checkout-pane-payment-information input[value="new--paypal_checkout--paypal_checkout"] + label.option img {
  display: none;
}

/* Inline PayPal mark (two italic Ps in PayPal blues). */
.checkout-pane-payment-information input[value="new--paypal_checkout--paypal_checkout"] + label.option::before {
  content: "";
  display: inline-block;
  width: 50px;
  height: 24px;
  flex-shrink: 0;
  background-image: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 60 30'%3E%3Ctext x='2' y='25' font-family='Arial,sans-serif' font-weight='900' font-size='28' font-style='italic' fill='%23003087'%3EP%3C/text%3E%3Ctext x='18' y='25' font-family='Arial,sans-serif' font-weight='900' font-size='28' font-style='italic' fill='%23009cde'%3EP%3C/text%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

/* Synthetic credit-card icon for the Stripe option. */
.checkout-pane-payment-information input[value="stripe_payment_element"] + label.option::before {
  content: "";
  display: inline-block;
  width: 36px;
  height: 24px;
  flex-shrink: 0;
  background-image: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 32'%3E%3Crect x='2' y='3' width='44' height='26' rx='3' fill='none' stroke='%23555' stroke-width='2'/%3E%3Crect x='2' y='9' width='44' height='5' fill='%23555'/%3E%3Crect x='8' y='21' width='12' height='3' rx='1' fill='%23555'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

/* Keyboard focus indicator (since the visual radio is hidden). */
.checkout-pane-payment-information input.payment-method--new[type="radio"]:focus + label.option {
  outline: 2px solid #2684ff;
  outline-offset: 4px;
  border-radius: 4px;
}

/* =============================================================================
   agree_terms and order_fields:checkout — both now render as real fieldsets,
   so the existing .commerce-checkout-flow-multistep-default legend rule
   already styles their headers. No additional rules needed.
   ============================================================================= */

/* =============================================================================
   Submit ("Review order") — force a full-width button at the bottom of the
   main column. Older theme rules in skin/* leave the actions container in a
   collapsed state where the button renders as a tiny floated rectangle.
   ============================================================================= */

form.commerce-checkout-flow-multistep-default #edit-actions {
  display: block !important;
  width: 100% !important;
  clear: both !important;
  float: none !important;
  position: static !important;
  margin: 25px 0 0 !important;
  padding: 0 !important;
  text-align: left;
}

form.commerce-checkout-flow-multistep-default input#edit-actions-next,
form.commerce-checkout-flow-multistep-default a.link--previous {
  display: inline-block !important;
  box-sizing: border-box !important;
  width: auto !important;
  min-width: 200px;
  margin: 0 !important;
  padding: 12px 30px !important;
  font-family: inherit;
  font-size: 16px !important;
  font-weight: 500 !important;
  line-height: 1.2 !important;
  color: #fff !important;
  background: #14723c !important;
  border: 0 !important;
  border-radius: 4px !important;
  cursor: pointer;
  position: static !important;
  float: none !important;
  text-align: center;
  text-decoration: none !important;
  vertical-align: middle;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

/* =============================================================================
   Neutralise the broad `input:hover { background: #1894CD }` rule from
   skin/substyle.css for checkout form inputs.
   ============================================================================= */

form.commerce-checkout-flow-multistep-default input[type="text"]:hover,
form.commerce-checkout-flow-multistep-default input[type="email"]:hover,
form.commerce-checkout-flow-multistep-default input[type="tel"]:hover,
form.commerce-checkout-flow-multistep-default input[type="number"]:hover,
form.commerce-checkout-flow-multistep-default input[type="password"]:hover {
  background: #fff;
}

/* =============================================================================
   Secondary sidebar layout — the existing outline from skin/james.css wraps
   the whole secondary region (including the new PayPal banner). Move it onto
   the inner .my-basket wrapper so it surrounds only the basket contents.
   ============================================================================= */

.layout-region-checkout-secondary {
  outline: none !important;
}

.layout-region-checkout-secondary .my-basket {
  outline: 1px solid #eeeff2;
  display: flow-root;
}

/* The existing rule in barjo-d10.css targets `.layout-region-checkout-secondary
   > h3` (direct child only). Now that the h3 sits inside .my-basket, the
   direct-child selector no longer matches, so re-apply the styling here. */
.layout-region-checkout-secondary .my-basket > h3 {
  background: #14723c !important;
  color: #fff !important;
  padding: 8px 15px;
  width: 100%;
  float: left;
  font-size: 20px;
  font-weight: 500;
}

.paypal-trust-banner {
  width: 351px;
  background: url(https://cdn.barjo.co.uk/public/paypal-lg.jpg) no-repeat #0000;
  background-position: center top;
  padding-top: 130px;
  margin-top: 20px;
}
