/* =====================================================
   Flight Review — Add-ons step, baggage cards
   =====================================================

   Scoped to `.fb-bagcard` / `.fb-baggroup`, which nothing else on the site
   uses, so this cannot reach past the add-ons pane it is written for.

   Kept here rather than in a global sheet for the reason flight-review.css
   documents at length: the globals already carry `.filter-radio-*`, and a
   second set of single-class selectors for the same idea would be resolved by
   stylesheet order rather than by intent. These cards deliberately do NOT reuse
   `.filter-radio-buttons` — that rule paints hover and checked identically
   (flight-form-style.css:209), which is exactly the distinction a card design
   needs to keep.

   Colours come from the `:root` block in leisure-new-style.css. The one
   exception is the selected tint, handled the same way flight-form-style.css
   already handles it — see `.fb-bagcard.is-selected` below.
   ===================================================== */

/* ── The card ──────────────────────────────────────────────────────────────

   A grid, not a flex row, so the price can move to its own full-width line on
   a phone without the markup changing order. `position: relative` anchors the
   stretched hit area.                                                        */
.fb-bagcard {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas: "art body action";
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid var(--color-gray-2);
  border-radius: 12px;
  background: var(--color-white);
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

/*
  The hit area: the whole card, as the design asks for.

  An overlay rather than a wrapper, because the Remove button has to sit ABOVE
  it and outside it — a <button> inside a <label> re-triggers the label as the
  click bubbles, which would deselect and instantly reselect the card. See the
  BagCard comment in PaneAddOns.tsx.
*/
.fb-bagcard__hit {
  position: absolute;
  inset: 0;
  z-index: 1;
  margin: 0;
  border-radius: inherit;
  cursor: pointer;
}

/* Statements, not choices — the Included card on a fare that prices its legs
   separately. No pointer, no hover, and visibly quieter than a real option. */
.fb-bagcard.is-static {
  background: var(--bgColor-light);
  cursor: default;
}

.fb-bagcard:hover:not(.is-static):not(.is-selected) {
  border-color: var(--color-first);
}

/*
  Selected.

  Three signals at once, never colour alone: a 2px border where every other
  card has 1px, a tinted ground, and — from the component — an action that
  changes from "Add for $192" to "✓ Added · Remove".

  The tint is `--color-second-light`, a fixed pale pink, so dark mode gets the
  same override flight-form-style.css:431 already applies to the radio rows
  this replaces: fall back to the surface colour and let the border carry the
  state. Without it a pink panel would sit under `--color-content`'s light-grey
  dark-mode text.
*/
.fb-bagcard.is-selected {
  border: 2px solid var(--color-second);
  background: var(--color-second-light);
  /* The extra border pixel must not nudge the row's height. */
  padding: 13px 15px;
}

html[data-bs-theme="dark"] .fb-bagcard.is-selected {
  background: var(--color-white);
}

/* Keyboard focus. The radio itself is clipped by `.visually-hidden`, so its own
   ring is invisible and the card wears one on its behalf. */
.fb-bagcard:has(input:focus-visible) {
  outline: 2px solid var(--color-first);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .fb-bagcard,
  .fb-bagcard__remove {
    transition: none;
  }
}

/* ── Card contents ───────────────────────────────────────────────────────── */

.fb-bagcard__art {
  grid-area: art;
  width: 96px;
  height: 96px;
  object-fit: contain;
}

.fb-bagcard__body {
  grid-area: body;
  min-width: 0;
}

.fb-bagcard__title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
  color: var(--color-dark);
}

.fb-bagcard__desc,
.fb-bagcard__allowance {
  font-size: 13px;
  color: var(--color-content);
}

.fb-bagcard__desc {
  margin-top: 2px;
}

.fb-bagcard__pill {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--color-blue-light);
  color: var(--color-first);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.6;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

/* ── The action cell ─────────────────────────────────────────────────────── */

.fb-bagcard__action {
  /*
    Above the hit overlay so the Remove button inside it is reachable — but
    transparent to clicks by default, or the cell's own padding would be a dead
    zone in the middle of a card the design says is clickable everywhere. Only
    the button takes its clicks back.
  */
  grid-area: action;
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: flex-end;
  pointer-events: none;
}

/*
  "Add for $192".

  A <span>, not a <button>. The whole card is already the control — a nested
  button would be a second tab stop for the same action and would fight the
  label overlay. It is styled as a button because that is the affordance the
  design wants; the cell's `pointer-events: none` above is what keeps the click
  going to the card beneath it.
*/
.fb-bagcard__price,
.fb-bagcard__included,
.fb-bagcard__remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 16px;
  border: 0;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

/*
  Soft fill, in the blue-light pair rather than the coral one.

  Coral was the obvious first choice and it does not pass: `--color-second-dark`
  on `--color-second-light` measures 4.42:1, just under the 4.5:1 this 13px
  semibold text needs, and white on `--color-second` is 3.16:1. The blue-light /
  first pairing is the repo's existing soft-fill (`.fs-list-item.is-selected`),
  is a real light-dark() pair so it holds up in both themes — 6.04:1 light,
  5.73:1 dark — and it leaves coral to the page's one primary CTA, Continue to
  Payment. The reference design's own price buttons are a soft green, so a
  non-coral fill is what it was asking for anyway.
*/
.fb-bagcard__price {
  background: var(--color-blue-light);
  color: var(--color-first);
}

.fb-bagcard__included {
  background: transparent;
  color: var(--color-first);
  padding-inline: 0;
}

/*
  Solid coral, darkening on hover — the same treatment every other CTA in the
  app wears (Search Flights, Continue To Payment, View Fares), so this button
  does not read as a one-off. Solid where the unselected price is a soft fill,
  so the two states differ in weight as well as in words.

  White on `--color-second` measures 3.16:1, under the 4.5:1 this 13px semibold
  text wants. Called out and kept deliberately: matching the product's existing
  buttons was chosen over fixing one of them in isolation, and the selected
  state does not depend on this text being read — the border, the tint and the
  word "Added" all carry it. The hover, at 5.35:1, does pass.
*/
.fb-bagcard__remove {
  background: var(--color-second);
  color: var(--color-white-same);
  cursor: pointer;
  /* The one thing in this cell that is its own control. */
  pointer-events: auto;
  transition: background-color 0.2s ease;
}

.fb-bagcard__remove:hover,
.fb-bagcard__remove:focus-visible {
  background: var(--color-second-dark);
}

.fb-bagcard__remove:focus-visible {
  outline: 2px solid var(--color-first);
  outline-offset: 2px;
}

/* ── The group ───────────────────────────────────────────────────────────── */

.fb-baggroup {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

/*
  A real <legend>, so the cards inside are announced as one named group.

  Reset off its default `<fieldset>` positioning — Bootstrap's Reboot sizes
  legends at 1.5rem and floats them full-width, which is not what a small
  section label wants.
*/
.fb-baggroup__legend {
  float: none;
  width: auto;
  margin-bottom: 8px;
  padding: 0;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--color-content);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.fb-baggroup__scope {
  font-weight: 500;
  text-transform: none;
  letter-spacing: normal;
}

/* The Included card sits above this list when it is the group's "none" choice,
   so the gap belongs on the group rather than between the cards alone. */
.fb-baggroup > .fb-bagcard {
  margin-bottom: 12px;
}

.fb-baggroup__cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ── Phone ───────────────────────────────────────────────────────────────────

   Below `sm`. The illustration shrinks to 64px and the action drops to its own
   full-width line under the text, which is also what finally gives Remove a
   44px touch target without it crowding the price on a narrow row.            */
@media (max-width: 575.98px) {
  .fb-bagcard {
    grid-template-columns: 64px minmax(0, 1fr);
    grid-template-areas:
      "art  body"
      "action action";
    gap: 12px;
    padding: 12px;
  }

  .fb-bagcard.is-selected {
    padding: 11px;
  }

  .fb-bagcard__art {
    width: 64px;
    height: 64px;
    align-self: start;
  }

  .fb-bagcard__action {
    justify-content: stretch;
  }

  .fb-bagcard__price,
  .fb-bagcard__remove {
    width: 100%;
    min-height: 44px;
  }

  /* Not a control, so it keeps its natural width and stays left-aligned with
     the text above it rather than stretching into a fake button. */
  .fb-bagcard__included {
    justify-content: flex-start;
    min-height: 0;
  }
}
