/*
  Subscription configurator cards (subscription-consolidated template only)

  Loaded only on product.subscription-consolidated, after product.css (see
  layout/theme.liquid). Selectors must keep outranking the generic
  .variant-button-wrap rules in product.css (:checked ring, disabled
  strike-through, focus box-shadow).

  Structure lives here; each store sets its palette and sizing through the
  --sub-* tokens in its store-overrides.css (on body[data-template=...]).
  Tokens are read via var() so store-overrides wins regardless of load order.
  Fallbacks below are the Heyrooted sizing; colours fall back to theme vars.
*/
body[data-template='product.subscription-consolidated'] {
  block-variant-picker,
  selling-plan-picker {
    .variant-button-wrap {
      color: var(--sub-text, var(--color-text-body));
    }

    .variant__label {
      margin-bottom: var(--sub-legend-margin, 12px);
      font-size: var(--sub-legend-size, inherit);
      font-weight: var(--sub-legend-weight, var(--type-header-weight));
      letter-spacing: var(--sub-legend-spacing, 0.12em);
      text-transform: var(--sub-legend-transform, uppercase);
    }

    /* "Plant type: Pet Friendly" — selected value next to the legend (off by default). */
    .variant__label-selected {
      display: var(--sub-legend-value-display, none);
      font-weight: 400;
      text-transform: none;
      letter-spacing: normal;
    }

    .variant__button-label-wrapper {
      width: 100%;
      margin: 0;
      text-align: left;
    }

    .variant__button-label {
      display: flex;
      position: relative;
      width: 100%;
      margin: 0;
      overflow: visible;
      color: inherit;
      background: var(--sub-card-bg, transparent);
      border: var(--sub-card-border-width, 1px) solid var(--sub-card-border, var(--color-border));
      border-radius: var(--sub-card-radius, 18px);
      box-shadow: none;
      cursor: pointer;
      transition:
        color 0.2s ease,
        background-color 0.2s ease,
        border-color 0.2s ease;
    }

    /* Beat the generic .variant-button-wrap focus ring / disabled text colour. */
    input[type='radio']:focus + .variant__button-label-wrapper > .variant__button-label {
      box-shadow: none;
    }

    input[type='radio'][data-disabled] + .variant__button-label-wrapper > .variant__button-label {
      color: inherit;
    }

    input[type='radio']:focus-visible + .variant__button-label-wrapper > .variant__button-label {
      outline: 1px solid var(--sub-focus, var(--color-text-body));
      outline-offset: 3px;
    }

    input[data-disabled] + .variant__button-label-wrapper {
      opacity: 0.45;
    }

    .variant__button-title,
    .selling-plan-option__title {
      display: block;
      font-size: var(--sub-title-size, calc(var(--type-base-size) + 2px));
      font-weight: var(--sub-title-weight, 700);
      line-height: 1.2;
    }

    .variant__button-description,
    .selling-plan-option__description {
      display: block;
      margin-top: var(--sub-desc-margin, 4px);
      color: var(--sub-desc-color, inherit);
      font-size: var(--sub-desc-size, 14px);
      font-weight: 400;
      line-height: 1.3;
      opacity: var(--sub-desc-opacity, 0.72);
    }

    .selling-plan-option__description {
      font-size: var(--sub-plan-desc-size, var(--sub-desc-size, 14px));
    }
  }

  /* Variant option cards (Size, Subscription Type, Plant type, …) */
  block-variant-picker {
    .variant-button-options {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: var(--sub-gap, 12px);
    }

    .variant__button-label {
      flex-direction: column;
      justify-content: center;
      min-height: var(--sub-variant-min-height, 0);
      padding: var(--sub-variant-padding, 12px 32px 12px 12px);
    }

    /* input[type=radio] prefix outranks the generic disabled strike-through ::after. */
    input[type='radio'] + .variant__button-label-wrapper > .variant__button-label::after {
      content: '\2713';
      display: grid;
      position: absolute;
      top: var(--sub-check-top, 16px);
      right: var(--sub-check-right, 8px);
      left: auto;
      bottom: auto;
      place-items: center;
      width: var(--sub-check-size, 20px);
      height: var(--sub-check-size, 20px);
      color: var(--sub-check-fg, var(--color-body));
      background: var(--sub-check-bg, var(--color-text-body));
      border: 1px solid var(--sub-check-border, var(--sub-check-fg, var(--color-body)));
      border-radius: 50%;
      font-size: var(--sub-check-font-size, 13px);
      font-weight: 700;
      line-height: 1;
      opacity: 0;
      transform: scale(0.75);
      transition:
        opacity 0.2s ease,
        transform 0.2s ease;
    }

    input[type='radio']:checked + .variant__button-label-wrapper > .variant__button-label {
      color: var(--sub-selected-text, var(--color-body));
      background: var(--sub-selected-bg, var(--color-text-body));
      border-color: var(--sub-selected-border, var(--color-text-body));
      box-shadow: none;
    }

    input[type='radio']:checked + .variant__button-label-wrapper > .variant__button-label::after {
      opacity: 1;
      transform: scale(1);
    }
  }

  /* Selling plan rows */
  selling-plan-picker {
    display: block;

    .variants-selling-plans {
      display: grid;
      grid-template-columns: repeat(var(--sub-plan-columns, 1), minmax(0, 1fr));
      gap: var(--sub-gap, 12px);
    }

    .variant__button-label {
      align-items: center;
      justify-content: space-between;
      gap: var(--sub-plan-gap, 14px);
      padding: var(--sub-plan-padding, 12px);
    }

    input[type='radio']:checked + .variant__button-label-wrapper > .variant__button-label {
      background: var(--sub-plan-selected-bg, var(--color-body));
      border-color: var(--sub-plan-selected-border, var(--color-text-body));
      box-shadow: var(--sub-plan-selected-shadow, none);
    }

    .selling-plan-option__radio-ctr {
      display: flex;
      align-items: center;
      gap: var(--sub-radio-gap, 10px);
      min-width: 0;
    }

    .selling-plan-option__radio {
      display: grid;
      flex-shrink: 0;
      place-items: center;
      width: var(--sub-radio-size, 24px);
      height: var(--sub-radio-size, 24px);
      border: var(--sub-radio-border-width, 1px) solid var(--sub-radio-border, var(--color-border));
      border-radius: 50%;
      transition: border-color 0.2s ease;

      &::after {
        content: '';
        width: var(--sub-radio-dot, 12px);
        height: var(--sub-radio-dot, 12px);
        background: var(--sub-radio-selected, var(--color-text-body));
        border-radius: 50%;
        opacity: 0;
        transform: scale(0.5);
        transition:
          opacity 0.2s ease,
          transform 0.2s ease;
      }
    }

    input[type='radio']:checked + .variant__button-label-wrapper .selling-plan-option__radio {
      border-color: var(--sub-radio-selected, var(--color-text-body));

      &::after {
        opacity: 1;
        transform: scale(1);
      }
    }

    .selling-plan-option__title,
    .variant__label-selected [data-selected-selling-plan-label] {
      text-transform: var(--sub-plan-title-transform, none);
    }

    .selling-plan-option__content {
      min-width: 0;
    }

    .selling-plan-option__pricing {
      display: var(--sub-pricing-display, flex);
      flex: 0 0 auto;
      flex-direction: column;
      align-items: flex-end;
      text-align: right;
    }

    .selling-plan-option__price {
      font-size: calc(var(--type-base-size) + 2px);
      font-weight: 700;
      line-height: 1.2;
      white-space: nowrap;
    }

    .selling-plan-option__price-detail {
      display: block;
      margin-top: 4px;
      font-size: var(--type-base-size);
      font-weight: 400;
      line-height: 1.2;
      opacity: 0.72;
      white-space: nowrap;
    }
  }

  @media screen and (max-width: 576px) {
    block-variant-picker,
    selling-plan-picker {
      .variant__button-label {
        border-radius: var(--sub-card-radius-mobile, 8px);
      }

      .variant__button-description,
      .selling-plan-option__description {
        font-size: var(--sub-desc-size-mobile, 12px);
      }
    }

    block-variant-picker .variant__button-label {
      padding: var(--sub-variant-padding-mobile, 8px 12px 8px 8px);
    }

    selling-plan-picker {
      .variant__button-label {
        gap: var(--sub-plan-gap-mobile, 10px);
        padding: var(--sub-plan-padding-mobile, 8px 12px 8px 8px);
      }

      .selling-plan-option__description {
        font-size: var(--sub-plan-desc-size-mobile, var(--sub-desc-size-mobile, 12px));
      }

      .selling-plan-option__radio {
        width: var(--sub-radio-size-mobile, 22px);
        height: var(--sub-radio-size-mobile, 22px);

        &::after {
          width: var(--sub-radio-dot-mobile, 10px);
          height: var(--sub-radio-dot-mobile, 10px);
        }
      }
    }
  }
}
