/* Opt in with the native Avada container anchor "bckfc-tickets".
   The container supplies full width; its normal inner row keeps content aligned. */
#main #bckfc-tickets {
  --bckfc-ticket-padding: var(--bckfc-space-4);
  scroll-margin-top: 100px;
}

#main #bckfc-tickets > .fusion-fullwidth {
  padding: var(--bckfc-space-10) 0;
  background: var(--bckfc-tan);
}

/* Avada's row z-index traps the fixed Tribe modal behind the page footer. */
#main #bckfc-tickets > .fusion-fullwidth > .fusion-builder-row {
  z-index: auto;
}

#main #bckfc-tickets .fusion-layout-column {
  margin-top: 0;
  margin-bottom: 0;
}

#main #bckfc-tickets .tribe-tickets__tickets-wrapper {
  max-width: 100%;
}

/* Keep native ticket behavior and states; style only the BCKFC ticket section. */
#main #bckfc-tickets .event-tickets {
  --tec-font-family-sans-serif: var(--bckfc-font-body);
  --body_typography-font-family: var(--bckfc-font-body);
  --tec-color-accent-primary: var(--bckfc-orange);
  --tec-color-accent-primary-hover: var(--bckfc-orange-hover);
  --tec-color-text-primary: var(--bckfc-ink);
  --tec-color-text-secondary: var(--bckfc-muted);
  --tec-color-border-secondary: var(--bckfc-border);
  font-family: var(--bckfc-font-body);
}

/* Heading and notices.
   Our intro is inside Tribe's form. The site's broad reset gives divs,
   spans and links 3px padding; reset only our own presentation elements. */
#main #bckfc-tickets :is(.bckfc-ticket-intro, .bckfc-ticket-heading),
#main #bckfc-tickets .bckfc-notice > span,
#main #bckfc-tickets .bckfc-notice .bckfc-link,
#main #bckfc-tickets .bckfc-registration-deadline > span {
  padding: 0;
}

#main #bckfc-tickets .bckfc-ticket-intro {
  display: grid;
  gap: var(--bckfc-space-2);
  margin: 0 0 var(--bckfc-space-3);
}

#main #bckfc-tickets .bckfc-ticket-heading {
  display: flex;
  flex-direction: column-reverse;
  gap: var(--bckfc-space-4);
}

#main #bckfc-tickets :is(.bckfc-ticket-purchase-instructions, .bckfc-registration-deadline) {
  margin: 0;
  color: var(--bckfc-ink);
  font-family: var(--bckfc-font-body);
}

#main #bckfc-tickets .bckfc-ticket-purchase-instructions {
  padding: var(--bckfc-space-1) var(--bckfc-space-2);
  border-left: 3px solid var(--bckfc-orange);
  font-weight: 600;
}

#main #bckfc-tickets .bckfc-registration-deadline {
  display: flex;
  align-items: flex-start;
  gap: var(--bckfc-space-2);
  padding: 0;
}

#main #bckfc-tickets .bckfc-registration-deadline svg {
  margin-top: 2px;
  color: var(--bckfc-orange);
}

/* Page picker. */
#main #bckfc-tickets .tribe-tickets__tickets-form {
  max-width: none;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

#main #bckfc-tickets .tribe-tickets__tickets-form .tribe-tickets__tickets-item {
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--bckfc-space-1) var(--bckfc-space-4);
  padding: var(--bckfc-space-4) var(--bckfc-ticket-padding);
  margin: 0;
  border: 1px solid var(--bckfc-border);
  border-bottom: 0;
  background: var(--bckfc-white);
}

#main #bckfc-tickets
  .tribe-tickets__tickets-form
  .tribe-tickets__tickets-item-content-title-container {
  grid-column: 1 / -1;
  grid-row: 1;
  min-width: 0;
  padding: 0;
  overflow-wrap: anywhere;
}

#main #bckfc-tickets
  .tribe-tickets__tickets-form
  .tribe-tickets__tickets-item-details-content:not(.tribe-common-a11y-hidden) {
  display: block;
  grid-column: 1 / -1;
  grid-row: 2;
  margin: 0 0 var(--bckfc-space-2);
  line-height: 1.5;
  overflow-wrap: anywhere;
}

/* Native description classes change size by breakpoint; use our body role instead. */
#main #bckfc-tickets
  :is(.tribe-tickets__tickets-form, .tribe-modal__content)
  .tribe-tickets__tickets-item-details-content {
  padding: 0;
  font-family: var(--bckfc-font-body);
  font-size: var(--bckfc-text-body);
  line-height: 1.5;
  color: var(--bckfc-muted);
}

#main #bckfc-tickets .tribe-tickets__tickets-form .tribe-tickets__tickets-item-content-title {
  padding: 0;
  color: var(--bckfc-ink);
}

#main #bckfc-tickets .tribe-tickets__tickets-form .tribe-tickets__tickets-item-extra {
  grid-column: 1;
  grid-row: 3;
  padding: 0;
  text-align: left;
}

#main #bckfc-tickets .tribe-tickets__tickets-form .tribe-tickets__tickets-item-extra-price {
  font-size: var(--bckfc-text-lead);
  font-weight: 700;
  color: var(--bckfc-ink);
}

#main #bckfc-tickets .tribe-tickets__tickets-form .tribe-tickets__tickets-item-extra-price,
#main #bckfc-tickets .tribe-tickets__tickets-form .tribe-tickets__tickets-item-extra-price span {
  padding: 0;
}

#main #bckfc-tickets .tribe-tickets__tickets-form .tribe-tickets__tickets-item-quantity {
  grid-column: 2;
  grid-row: 3;
  align-self: center;
  padding: 0;
}

#main #bckfc-tickets .tribe-tickets__tickets-form .tribe-tickets__tickets-footer {
  flex-wrap: wrap;
  align-items: center;
  gap: var(--bckfc-space-4);
  margin: 0;
  padding: var(--bckfc-space-4) var(--bckfc-ticket-padding);
  border: 1px solid var(--bckfc-border);
  background: var(--bckfc-white);
}

#main #bckfc-tickets
  .tribe-tickets__tickets-form
  :is(.tribe-tickets__tickets-footer-total, .tribe-tickets__tickets-footer-quantity) {
  margin: 0;
  padding: 0;
  order: 0;
}

#main #bckfc-tickets
  :is(.tribe-tickets__tickets-form, .tribe-modal__content)
  :is(.tribe-tickets__tickets-footer-total, .tribe-tickets__tickets-footer-quantity) {
  font-family: var(--bckfc-font-body);
  font-size: var(--bckfc-text-body);
  line-height: 1.5;
  color: var(--bckfc-muted);
}

/* Currency markup has nested spans; inherit the summary role through that markup. */
#main #bckfc-tickets
  :is(.tribe-tickets__tickets-form, .tribe-modal__content)
  :is(.tribe-tickets__tickets-footer-total, .tribe-tickets__tickets-footer-quantity) :where(span) {
  padding: 0;
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

#main #bckfc-tickets
  :is(.tribe-tickets__tickets-form, .tribe-modal__content)
  :is(.tribe-tickets__tickets-footer-total-wrap, .tribe-tickets__tickets-footer-quantity-number) {
  color: var(--bckfc-ink);
  font-weight: 700;
}

#main #bckfc-tickets .tribe-tickets__tickets-form .tribe-tickets__tickets-buy {
  order: 1;
  width: 100%;
  margin: 0;
}

#main #bckfc-tickets
  .tribe-tickets__tickets-form
  :is(button, input):not(.tribe-tickets__tickets-buy, .qty, .minus, .plus):focus-visible {
  outline: 2px solid var(--bckfc-ink);
  outline-offset: 3px;
}

/* Avada replaces Tribe's visible +/- buttons with .quantity.buttons_added.
   One joined control treatment serves both the page picker and attendee modal. */
#main #bckfc-tickets
  :is(.tribe-tickets__tickets-form, .tribe-modal__content)
  .tribe-tickets__tickets-item-quantity-number {
  width: auto;
  height: auto;
  padding: 0;
  border: 0;
}

#main #bckfc-tickets
  :is(.tribe-tickets__tickets-form, .tribe-modal__content)
  .quantity.buttons_added {
  display: inline-flex;
  align-items: center;
  gap: 0;
  width: auto;
  height: auto;
  margin: 0;
  padding: 0;
  border: 1px solid var(--bckfc-border);
  border-radius: var(--bckfc-radius);
  background: var(--bckfc-white);
}

#main #bckfc-tickets
  :is(.tribe-tickets__tickets-form, .tribe-modal__content)
  .quantity :is(.minus, .qty, .plus) {
  box-sizing: border-box;
  flex: 0 0 var(--bckfc-quantity-size, var(--bckfc-control-height-compact));
  width: var(--bckfc-quantity-size, var(--bckfc-control-height-compact));
  height: var(--bckfc-quantity-size, var(--bckfc-control-height-compact));
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--bckfc-muted);
  font-family: var(--bckfc-font-body);
  font-size: var(--bckfc-text-lead);
  font-weight: 400;
  line-height: 1;
  text-align: center;
}

#main #bckfc-tickets
  :is(.tribe-tickets__tickets-form, .tribe-modal__content)
  .quantity .qty {
  color: var(--bckfc-ink);
  font-weight: 700;
}

#main #bckfc-tickets
  :is(.tribe-tickets__tickets-form, .tribe-modal__content)
  .quantity .minus {
  border-radius: var(--bckfc-radius) 0 0 var(--bckfc-radius);
}

#main #bckfc-tickets
  :is(.tribe-tickets__tickets-form, .tribe-modal__content)
  .quantity .plus {
  border-radius: 0 var(--bckfc-radius) var(--bckfc-radius) 0;
}

#main #bckfc-tickets
  :is(.tribe-tickets__tickets-form, .tribe-modal__content)
  .quantity :is(.minus, .plus):hover:not(:disabled) {
  background: var(--bckfc-gray);
}

#main #bckfc-tickets
  :is(.tribe-tickets__tickets-form, .tribe-modal__content)
  .quantity :is(.minus, .qty, .plus):focus-visible {
  outline: 2px solid var(--bckfc-ink);
  outline-offset: -2px;
}

/* White controls sit on shaded attendee groups within a white dialog.
   Ticket names share the item-heading role; attendee and field headings use the body family. */
#main #bckfc-tickets .tribe-modal__wrapper--ar {
  --bckfc-modal-padding: var(--bckfc-space-6);
  --bckfc-quantity-size: 2.25rem;
  padding: 0;
  background: var(--bckfc-white);
  border-top: 4px solid var(--bckfc-orange);
  border-radius: var(--bckfc-radius);
}

#main #bckfc-tickets .tribe-modal__wrapper--ar > [role='document'],
#main #bckfc-tickets .tribe-modal__content,
#main #bckfc-tickets .tribe-modal__content :is(.tribe-tickets__form, .tribe-modal__cart, .tribe-tickets__attendee-tickets, .tribe-tickets__attendee-tickets-form) {
  padding: 0;
  margin: 0;
}

#main #bckfc-tickets .tribe-modal__wrapper--ar .tribe-dialog__close-button {
  width: var(--bckfc-control-height-compact);
  height: var(--bckfc-control-height-compact);
  background-size: 18px;
  background-position: center;
  background-repeat: no-repeat;
  top: 0;
  right: 0;
  background-color: transparent;
}

#main #bckfc-tickets .tribe-modal__wrapper--ar .tribe-dialog__title {
  box-sizing: border-box;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: var(--bckfc-space-7) var(--bckfc-space-12) var(--bckfc-space-7) var(--bckfc-modal-padding);
  background: var(--bckfc-ink);
  border-bottom: 1px solid var(--bckfc-border);
  font-family: var(--bckfc-font-heading);
  font-size: var(--bckfc-text-section);
  font-weight: 600;
  line-height: 1.2;
  color: var(--bckfc-white);
}

#main #bckfc-tickets .tribe-modal__content .tribe-tickets__attendee-tickets-item-title {
  margin: 0 0 var(--bckfc-space-4);
  padding: 0;
  color: var(--bckfc-blue);
}

#main #bckfc-tickets .tribe-modal__content .tribe-tickets__attendee-tickets-item {
  margin: var(--bckfc-space-3) 0 0;
  padding: var(--bckfc-space-5);
  background: var(--bckfc-gray-subtle);
  border: 1px solid var(--bckfc-border);
  border-radius: var(--bckfc-radius);
}

#main #bckfc-tickets .tribe-modal__content .tribe-tickets__attendee-tickets-container {
  background: var(--bckfc-tan);
  padding: var(--bckfc-space-5) var(--bckfc-modal-padding);
  margin: 0;
}

#main #bckfc-tickets .tribe-modal__content .tribe-tickets__attendee-tickets-footer {
  margin: 0;
  padding: var(--bckfc-space-5) var(--bckfc-modal-padding);
  border-top: 1px solid var(--bckfc-border);
}

#main #bckfc-tickets .tribe-modal__content .tribe-tickets__tickets-footer {
  background: var(--bckfc-gray-subtle);
  margin: 0;
  padding: var(--bckfc-space-3) var(--bckfc-modal-padding);
  border-bottom: 1px solid var(--bckfc-border);
}

#main #bckfc-tickets .tribe-modal__content .tribe-tickets__form-field {
  margin: 0 0 var(--bckfc-space-4);
}

#main #bckfc-tickets .tribe-modal__content .tribe-tickets__form-field:last-child {
  margin-bottom: 0;
}

#main #bckfc-tickets .tribe-modal__content .tribe-tickets__form-field-description {
  color: var(--bckfc-muted);
}

#main #bckfc-tickets .tribe-modal__content :is(input[type='text'], input[type='tel'], input[type='email'], select) {
  min-height: var(--bckfc-control-height-compact);
  padding: var(--bckfc-space-2) var(--bckfc-space-3);
  border: 1px solid var(--bckfc-border);
  border-radius: var(--bckfc-radius);
  background-color: var(--bckfc-white);
  color: var(--bckfc-ink);
  font-family: var(--bckfc-font-body);
  font-size: var(--bckfc-text-body);
}

#main #bckfc-tickets .tribe-modal__content :is(input[type='text'], input[type='tel'], input[type='email'], select):focus-visible {
  outline: 2px solid var(--bckfc-blue);
  outline-offset: 2px;
}

/* Own field spacing here instead of accumulating the site's blanket 3px padding. */
#main #bckfc-tickets
  .tribe-modal__content
  :is(
    .tribe-tickets__form-field,
    .tribe-tickets__form-field-label,
    .tribe-tickets__form-field-label > span,
    .tribe-tickets__form-field-input-wrapper,
    .tribe-common-form-control-checkbox-radio-group,
    .tribe-common-form-control-checkbox,
    .tribe-common-form-control-radio,
    .tribe-tickets__form-field-description
  ) {
  padding: 0;
}

#main #bckfc-tickets .tribe-modal__content .tribe-tickets__form-field-label {
  flex: none;
  max-height: none;
  margin: 0 0 var(--bckfc-space-2);
  font-weight: 600;
}

#main #bckfc-tickets
  .tribe-modal__content
  :is(.tribe-tickets__form-field-input-wrapper, .tribe-common-form-control-checkbox-radio-group) {
  display: flex;
  flex-direction: column;
}

/* Descriptions are first within the controls wrapper, directly below its label. */
#main #bckfc-tickets
  .tribe-modal__content
  :is(.tribe-tickets__form-field-input-wrapper, .tribe-common-form-control-checkbox-radio-group)
  > .tribe-tickets__form-field-description {
  order: -1;
  margin: 0 0 var(--bckfc-space-2);
}

#main #bckfc-tickets .tribe-modal__content .tribe-common-form-control-checkbox-radio-group {
  gap: var(--bckfc-space-2);
}

#main #bckfc-tickets .tribe-modal__content .tribe-common-form-control-checkbox__label {
  box-sizing: border-box;
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--bckfc-space-2);
  min-height: var(--bckfc-control-height-compact);
  padding: var(--bckfc-space-2) var(--bckfc-space-3);
  margin: 0;
  border: 1px solid var(--bckfc-border);
  border-radius: var(--bckfc-radius);
  background: var(--bckfc-white);
  line-height: 1.4;
  cursor: pointer;
}

#main #bckfc-tickets .tribe-modal__content .tribe-common-form-control-checkbox__input {
  appearance: none;
  display: grid;
  place-content: center;
  border: 1px solid var(--bckfc-blue);
  border-radius: var(--bckfc-radius);
  background: var(--bckfc-white);
  color: var(--bckfc-blue);
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  min-height: 0;
  padding: 0;
  margin: 0;
  position: static;
}

#main #bckfc-tickets .tribe-modal__content .tribe-common-form-control-checkbox__input::before {
  content: none;
}

#main #bckfc-tickets .tribe-modal__content .tribe-common-form-control-checkbox__input::after {
  content: '';
  position: static;
  width: 5px;
  height: 10px;
  border: solid currentColor;
  border-width: 0 2px 2px 0;
  background: none;
  transform: translateY(-1px) rotate(45deg);
  visibility: hidden;
}

#main #bckfc-tickets .tribe-modal__content .tribe-common-form-control-checkbox__input:checked::after {
  visibility: visible;
}

#main #bckfc-tickets .tribe-modal__content .tribe-common-form-control-checkbox__input:focus-visible {
  outline: 2px solid var(--bckfc-blue);
  outline-offset: 3px;
}

/* Name above quantity and right-aligned price; the description remains on the event page. */
#main #bckfc-tickets .tribe-modal__content .tribe-tickets__tickets-item {
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--bckfc-space-2) var(--bckfc-space-3);
  padding: var(--bckfc-space-4) var(--bckfc-modal-padding);
  margin: 0;
  border: 0;
  border-bottom: 1px solid var(--bckfc-border);
  background: transparent;
}

#main #bckfc-tickets .tribe-modal__content .tribe-tickets__tickets-item-content-title-container {
  grid-column: 1 / -1;
  grid-row: 1;
  min-width: 0;
  padding: 0;
}

#main #bckfc-tickets .tribe-modal__content .tribe-tickets__tickets-item-content-title {
  overflow-wrap: anywhere;
}

#main #bckfc-tickets .tribe-modal__content .tribe-tickets__tickets-item-extra {
  grid-column: 2;
  grid-row: 2;
  align-self: center;
  text-align: right;
  padding: 0;
}

#main #bckfc-tickets .tribe-modal__content .tribe-tickets__tickets-item-extra-price,
#main #bckfc-tickets .tribe-modal__content .tribe-tickets__tickets-item-extra-price span {
  padding: 0;
  color: var(--bckfc-ink);
  font-family: var(--bckfc-font-body);
  font-size: var(--bckfc-text-body);
}

#main #bckfc-tickets .tribe-modal__content :is(.tribe-tickets__tickets-item-details-summary, .tribe-tickets__tickets-item-details-content) {
  display: none;
}

#main #bckfc-tickets .tribe-modal__content .tribe-tickets__tickets-item-quantity {
  grid-column: 1;
  grid-row: 2;
  align-self: center;
  justify-self: start;
  padding: 0;
}

#main #bckfc-tickets .tribe-modal__content .tribe-tickets__tickets-item-total-wrap {
  display: none;
}

#main #bckfc-tickets .tribe-modal__content .tribe-ticket__tickets-heading {
  margin: 0 0 var(--bckfc-space-3);
  padding: 0;
}

#main #bckfc-tickets .tribe-modal__content .tribe-common-form-control-checkbox__label:has(input:checked) {
  border-color: var(--bckfc-blue);
  background: color-mix(in srgb, var(--bckfc-blue) 6%, var(--bckfc-white));
}

/* Ticket names already identify the attendee forms. Tribe toggles the section
   heading with inline display styles for mixed carts, so this override is required. */
#main #bckfc-tickets .tribe-modal__content :is(.tribe-tickets__attendee-tickets-title, .tribe-tickets__notice--non-ar) {
  display: none !important;
}

/* Keep one clear purchase action in the attendee modal. */
#main #bckfc-tickets .tribe-modal__content .tribe-tickets__attendee-tickets-footer-cart-button,
#main #bckfc-tickets .tribe-modal__content .tribe-tickets__attendee-tickets-footer-divider {
  display: none;
}

/* Responsive page and dialog layout. */
@media (max-width: 767px) {
  /* Keep the native dialog within the visible viewport, including the admin bar. */
  #main #bckfc-tickets .tribe-dialog {
    top: var(--wp-admin--admin-bar--height, 0px);
    height: calc(100dvh - var(--wp-admin--admin-bar--height, 0px));
    padding: 0;
  }

  #main #bckfc-tickets .tribe-modal__wrapper--ar {
    box-sizing: border-box;
    width: 100%;
    height: auto;
    max-height: 100%;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    --bckfc-modal-padding: var(--bckfc-space-3);
  }

  #main #bckfc-tickets .tribe-modal__content .tribe-tickets__attendee-tickets-item {
    padding: var(--bckfc-space-3);
  }

  #main #bckfc-tickets .tribe-modal__content .tribe-tickets__attendee-tickets-footer {
    flex-direction: column;
    align-items: stretch;
    gap: var(--bckfc-space-2);
  }

  #main #bckfc-tickets
    .tribe-modal__content
    .tribe-tickets__attendee-tickets-footer-checkout-button {
    flex: 0 0 auto;
    width: 100%;
    margin: 0;
  }
}

@media (min-width: 768px) {
  #main #bckfc-tickets .tribe-modal__wrapper--ar {
    width: 600px;
    height: auto;
    max-height: calc(100dvh - 160px);
    overflow-y: auto;
  }

  #main #bckfc-tickets .bckfc-ticket-heading {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: var(--bckfc-space-6);
  }

  #main #bckfc-tickets {
    --bckfc-ticket-padding: var(--bckfc-space-8);
  }

  #main #bckfc-tickets > .fusion-fullwidth {
    padding-block: var(--bckfc-space-12);
  }

  #main #bckfc-tickets .tribe-tickets__tickets-form .tribe-tickets__tickets-item {
    grid-template-columns: minmax(0, 1fr) auto auto;
    column-gap: var(--bckfc-space-8);
  }

  #main #bckfc-tickets
    .tribe-tickets__tickets-form
    .tribe-tickets__tickets-item-content-title-container {
    grid-column: 1;
  }

  #main #bckfc-tickets
    .tribe-tickets__tickets-form
    .tribe-tickets__tickets-item-details-content:not(.tribe-common-a11y-hidden) {
    grid-column: 1;
    margin-bottom: 0;
  }

  #main #bckfc-tickets .tribe-tickets__tickets-form .tribe-tickets__tickets-item-extra {
    grid-column: 2;
    grid-row: 1 / span 2;
    align-self: center;
    text-align: right;
  }

  #main #bckfc-tickets .tribe-tickets__tickets-form .tribe-tickets__tickets-item-quantity {
    grid-column: 3;
    grid-row: 1 / span 2;
  }

  #main #bckfc-tickets .tribe-tickets__tickets-form .tribe-tickets__tickets-buy {
    width: auto;
    margin-left: auto;
  }
}

/* Presentation only; Tools enforces the login requirement on the server. */
#main #bckfc-tickets .bckfc-registration-gate {
  display: grid;
}

#main #bckfc-tickets .bckfc-registration-gate__content,
#main #bckfc-tickets .bckfc-registration-gate__prompt {
  grid-area: 1 / 1;
  min-width: 0;
}

#main #bckfc-tickets .bckfc-registration-gate__content {
  filter: blur(2px);
  opacity: 0.7;
  pointer-events: none;
  user-select: none;
}

#main #bckfc-tickets .bckfc-registration-gate__prompt {
  z-index: 1;
  display: grid;
  place-items: center;
  padding: var(--bckfc-space-6) var(--bckfc-space-3);
  text-align: center;
}

#main #bckfc-tickets .bckfc-registration-gate__prompt > div {
  max-width: 32rem;
}
