/*
 * The cart, on its page and in the panel next to the menu: the lines with a small stepper, the card that says what is
 * missing for a delivery, the totals, and the foot with the way on. The page is a column: the foot is at the bottom of
 * it and sticks above the tab bar while the lines scroll.
 */

@layer components {
  .cart-view {
    display: flex;
    flex-direction: column;
  }

  .cart-view__content {
    display: flex;
    flex: 1 0 auto;
    flex-direction: column;
  }

  /* The place the focus goes to when the line it was on is gone: no ring around the whole cart. */
  .cart-view__content:focus,
  .cart-panel__content:focus {
    outline: 0;
  }

  /*
   * Once a message has come up (it floats above the foot, over the end of the page) the end of the page has the room of it, as the
   * end of the pages with dishes has (the dock keeps it there): the last control, the link of the card of the points among them,
   * can be scrolled up out from under the message. The room stays for the rest of the page view, when the message has gone too,
   * so that nothing moves when it times out (toast_controller.js clears it when Turbo shows the next page). A page with room to
   * spare does not grow for it, and the page does not change before the first message.
   */
  .cart--page {
    padding-bottom: calc(var(--s-4) + var(--toast-end));
  }

  .cart--page > .order-type-form {
    margin: 0 var(--s-4) var(--s-2);
  }

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

  .line {
    display: flex;
    align-items: flex-start;
    gap: var(--s-3);
    padding: var(--s-3) var(--s-4);
    border-bottom: 1px solid var(--border);
  }

  .line__main {
    flex: 1;
    min-width: 0;
  }

  .line__name {
    font-weight: 700;
    overflow-wrap: anywhere;
  }

  .line__options {
    margin: 2px 0 var(--s-2);
    color: var(--muted);
    font-size: 0.875rem;
    overflow-wrap: anywhere;
  }

  /* The note for the kitchen, under the options: quiet, in quotes. */
  .line__note {
    margin: calc(var(--s-2) * -1 + 2px) 0 var(--s-2);
    color: var(--muted);
    font-size: 0.875rem;
    font-style: italic;
    overflow-wrap: anywhere;
  }

  .line__total {
    flex: none;
  }

  /* What is missing for a delivery: the card, the bar that fills up to the minimum, the tip. */
  .minimum__title {
    font-weight: 700;
  }

  .progress {
    display: block;
    width: 100%;
    height: 8px;
    margin: var(--s-2) 0;
    padding: 0;
    overflow: hidden;
    border: 0;
    border-radius: 4px;
    appearance: none;
    background: var(--surface-2);
  }

  .progress::-webkit-progress-bar {
    border-radius: 4px;
    background: var(--surface-2);
  }

  .progress::-webkit-progress-value {
    border-radius: 4px;
    background: var(--gold);
  }

  .progress::-moz-progress-bar {
    border-radius: 4px;
    background: var(--gold);
  }

  .minimum__hint {
    color: var(--muted);
    font-size: 0.875rem;
    line-height: 1.45;
  }

  .totals__list {
    margin: 0;
  }

  .totals__row {
    display: flex;
    justify-content: space-between;
    gap: var(--s-3);
    padding: 4px 0;
    font-size: 0.9375rem;
    font-variant-numeric: tabular-nums;
  }

  .totals__row dt,
  .totals__row dd {
    margin: 0;
  }

  /* "Spaarpunten (120) − € 6,00" above the total of the order box of the checkout: the colour of points. The script shows and hides it (`hidden`). */
  .totals__row--points {
    color: var(--gold-text);
    font-weight: 600;
  }

  .totals__row[hidden] {
    display: none;
  }

  .totals__row--total {
    margin-top: var(--s-2);
    padding-top: var(--s-2);
    border-top: 1px solid var(--border);
    font-size: 1.0625rem;
    font-weight: 700;
  }

  /* The way on: at the bottom of the page, and above the tab bar while the page scrolls. 12 + 52 + 12 + 1 pixels high. */
  .cart-foot {
    position: sticky;
    bottom: var(--bottom-bars);
    z-index: 21;
    margin-top: auto;
    padding: var(--s-3) var(--s-4);
    background: var(--surface);
    border-top: 1px solid var(--border);
  }

  /* Dishes that cannot be ordered any more, and (without JavaScript) the dish that was just removed. */
  .cart-notices {
    display: grid;
    gap: var(--s-2);
    margin: var(--s-3) var(--s-4) 0;
  }

  .cart-notices__removed {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--s-3);
    padding: var(--s-2) var(--s-4);
    border-radius: var(--r-md);
    background: var(--surface-2);
    font-weight: 600;
  }

  /* In the panel next to the menu the parts are not cards on a page but rows in one card. */
  .cart--panel {
    display: flex;
    flex: none;
    flex-direction: column;
    gap: var(--s-3);
  }

  .cart-panel__scroll {
    flex: none;
  }

  /*
   * A panel high enough for it (the height of the panel in rem, so large text counts): the lines and the minimum scroll between
   * the switch and the totals. The room around them (and the matching padding) is for the focus rings, which a scroller clips.
   * In a lower panel the box scrolls as a whole (cart-panel.css) and this is part of what scrolls.
   */
  @container cart-panel (min-height: 32rem) {
    .cart--panel {
      flex: 1 1 auto;
      min-height: 0;
    }

    .cart-panel__scroll {
      flex: 1 1 auto;
      min-height: 7rem;
      margin-inline: calc(var(--s-2) * -1);
      padding-inline: var(--s-2);
      overflow-y: auto;
      overscroll-behavior: contain;
    }
  }

  .cart--panel .cart-panel__scroll > .card {
    margin-top: var(--s-3);
  }

  .cart-panel__foot {
    display: flex;
    flex: none;
    flex-direction: column;
    gap: var(--s-3);
  }

  .cart--panel .line {
    padding-inline: 0;
  }

  .cart--panel .card {
    margin: 0;
    padding: var(--s-3) var(--s-4);
    background: var(--surface-2);
    box-shadow: none;
  }

  .cart--panel .progress {
    background: var(--surface);
  }

  .cart--panel .progress::-webkit-progress-bar {
    background: var(--surface);
  }
}
