/* The two plans as a card: the landing's price section and onboarding's plan step. */

@layer components {
  /* A faint brand wash falling from the card's top edge. */
  .plan_card {
    max-width: 34rem;
    margin: 0 auto;
    padding: clamp(1.5rem, 4vw, 2.5rem);
    text-align: left;
    background:
      linear-gradient(180deg, color-mix(in srgb, var(--color-primary) 7%, transparent), transparent 45%),
      var(--color-bg-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);

    /* With room, the picker stands to the left of the picked plan, the way a pricing page draws it. */
    @media (min-width: 48rem) {
      display: grid;
      grid-template-columns: 18rem 1fr;
      gap: 2.5rem;
      align-items: start;
      max-width: 50rem;

      .plan_card_action .btn {
        width: auto;
        padding-inline: 1.75rem;
      }
    }
  }

  /* The picker: each plan as a radio with its name and one line. The picked one lifts on the
     brand's edge and wash, and the panels follow the radios (the :has rules below). */
  .plan_card_picker {
    display: grid;
    gap: 0.25rem;
    margin-bottom: 1.5rem;
  }

  .plan_card_option {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0 0.625rem;
    padding: 0.75rem;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;

    &:has(.plan_card_pick:checked) {
      border-color: var(--color-primary);
      background: color-mix(in srgb, var(--color-primary) 5%, var(--color-bg-white));
    }
  }

  .plan_card_pick {
    appearance: none;
    grid-row: 1 / span 2;
    width: 18px;
    height: 18px;
    margin: 0.125rem 0 0;
    border: 1.5px solid var(--color-muted);
    border-radius: 50%;
    background: var(--color-bg-white);
    cursor: pointer;

    &:checked {
      border-color: var(--color-primary);
      background: var(--color-primary);
      box-shadow: inset 0 0 0 3px var(--color-bg-white);
    }

    &:focus-visible {
      outline: 2px solid var(--color-primary);
      outline-offset: 2px;
    }
  }

  .plan_card_option_name {
    font-size: var(--text-base);
    font-weight: var(--font-weight-semibold);
    line-height: 1.3;
    color: var(--color-text);
  }

  .plan_card_option_summary {
    grid-column: 2;
    font-size: var(--text-sm);
    line-height: var(--line-height-md);
    color: var(--color-text-light);
  }

  .plan_card:has(.plan_card_pick--free:checked) .plan_card_panel--paid,
  .plan_card:has(.plan_card_pick--paid:checked) .plan_card_panel--free {
    display: none;
  }

  /* The plan's name and its price on one line; the price and its period never split. */
  .plan_card_name {
    margin: 0;
    font-size: var(--text-2xl);
    font-weight: var(--font-weight-bold);
    line-height: 1.2;
    color: var(--color-text);
  }

  .plan_card_price {
    white-space: nowrap;

    small {
      font-size: var(--text-sm);
      font-weight: var(--font-weight-normal);
      color: var(--color-text-light);
    }
  }

  .plan_card_pitch {
    margin: 0.375rem 0 0;
    font-size: var(--text-base);
    line-height: var(--line-height-md);
    color: var(--color-text-light);
  }

  /* Mensal/Anual as a segmented pill: the pressed half lifts on the paper, the other rests
     in the wash. The plan-switch controller swaps the cadence shown and the action's plan. */
  .plan_card_switch {
    display: inline-flex;
    margin-bottom: 1rem;
    padding: 3px;
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-pill);
  }

  .plan_card_switch_option {
    padding: 0.375rem 1.125rem;
    border: 0;
    border-radius: var(--radius-pill);
    background: none;
    color: var(--color-text-light);
    font: inherit;
    font-size: var(--text-sm);
    font-weight: var(--font-weight-semibold);
    line-height: 1.4;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;

    &[aria-pressed="true"] {
      background: var(--color-bg-white);
      color: var(--color-text);
      box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
    }
  }

  /* What the yearly price comes to a month, under it, so the two cadences compare. */
  .plan_card_yearly_note {
    margin: 0.25rem 0 0;
    font-size: var(--text-sm);
    color: var(--color-text-light);
  }

  .plan_card_action {
    margin: 1rem 0 1.25rem;

    .btn {
      width: 100%;
      white-space: normal;
    }
  }

  /* In onboarding the column has no shell of its own and the plan is the page's one card,
     the way a pricing page draws it, so it keeps the landing's box and lifts on a shadow. */
  .onboarding .plan_card {
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.12);
  }

  [data-theme="dark"] .onboarding .plan_card {
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  }

  .plan_card_list {
    list-style: none;
    margin: 0;
    padding: 0;
  }

  /* A row of a plan's list: the check or the cross, then the name, what the plan gives and the (?). */
  .plan_card_item {
    position: relative;
    display: grid;
    grid-template-columns: 18px 1fr;
    gap: 0.5rem;
    padding: 0.3125rem 0;
    font-size: var(--text-base);
    line-height: var(--line-height-md);
    color: var(--color-text);

    &.plan_card_item--none {
      color: var(--color-muted);
    }
  }

  /* The row's mark: a filled brand dot where the plan says yes, an empty gray one where it
     doesn't. */
  .plan_card_check,
  .plan_card_cross {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    margin-top: 0.1875rem;
    border-radius: 50%;

    svg {
      stroke-width: 3;
    }
  }

  .plan_card_check {
    background: var(--color-primary);
    color: var(--color-on-brand);

    svg {
      width: 11px;
      height: 11px;
    }
  }

  .plan_card_cross {
    border: 1.5px solid var(--color-muted);
    color: var(--color-muted);

    svg {
      width: 10px;
      height: 10px;
    }
  }

  .plan_card_item_name--key {
    font-weight: var(--font-weight-semibold);
  }

  /* The (?) opens the sentences as a note above the line. On touch it is a tap: the dropdown
     controller toggles it and closes it on a tap elsewhere. Where there is a pointer it is hover
     alone, and a click does nothing. */
  .plan_card_item_help {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    margin-left: 0.375rem;
    padding: 0;
    vertical-align: 0.1em;
    border: 1px solid var(--color-border);
    border-radius: 50%;
    background: var(--color-bg-white);
    color: var(--color-text-light);
    font: inherit;
    font-size: var(--text-xs);
    font-weight: var(--font-weight-semibold);
    line-height: 1;
    cursor: pointer;

    &:focus-visible {
      border-color: var(--color-primary);
      color: var(--color-primary);
    }
  }

  .plan_card_item_text {
    position: absolute;
    left: 0;
    bottom: calc(100% + 0.375rem);
    z-index: var(--z-popup);
    width: min(22rem, 100%);
    padding: 0.75rem 0.875rem;
    background: var(--color-bg-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 24px -8px rgba(0, 0, 0, 0.25);
    font-size: var(--text-sm);
    line-height: var(--line-height-md);
    color: var(--color-text);
  }

  @media (hover: hover) {
    .plan_card_item_help:hover {
      border-color: var(--color-primary);
      color: var(--color-primary);
    }

    /* !important because .hidden carries it, and between two of them the earlier layer wins. */
    .plan_card_item_text {
      display: none !important;
    }

    .plan_card_item_help:hover ~ .plan_card_item_text,
    .plan_card_item_help:focus-visible ~ .plan_card_item_text {
      display: block !important;
    }
  }
}

/* The card's button is a pill wherever the card goes, the way the landing's buttons are. Outside
   the layer because the wizard button rule that squares it is unlayered too. */
.plan_card_action .btn {
  border-radius: var(--radius-pill);
}
