/* The recipe editor's ingredient grid (Công thức). One row per recipe line: picker | quantity | unit cost | line cost | remove.
   On a phone a row folds into two lines: picker and remove, then quantity, "× unit cost" and the cost on the right. */
@layer components {
  .rc-head,
  .rc-line {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 7.5rem 6.75rem 7.5rem 2.75rem;
    gap: 0.75rem;
    align-items: center;
  }

  .rc-head {
    padding: 0 1rem 0.6rem;
  }

  .rc-line {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #F5F0E1;
  }

  .rc-line:last-child {
    border-bottom: 0;
  }

  .rc-line[hidden] {
    display: none;
  }

  .rc-pick,
  .rc-qty {
    position: relative;
  }

  .rc-field {
    width: 100%;
    min-height: 2.75rem;
    padding: 0 0.75rem;
    border: 1px solid rgba(44, 44, 44, 0.2);
    border-radius: 8px;
    background: #fff;
    font-size: 1rem;
    color: #2C2C2C;
    font-variant-numeric: tabular-nums;
    transition: border-color 0.15s, box-shadow 0.15s;
  }

  .rc-field:focus {
    outline: none;
    border-color: #5B7A5E;
    box-shadow: 0 0 0 3px rgba(91, 122, 94, 0.12);
  }

  .rc-field.is-bad {
    border-color: #C5392F;
  }

  .rc-pick .rc-field {
    padding-right: 2.25rem;
  }

  .rc-caret {
    position: absolute;
    top: 50%;
    right: 0.75rem;
    transform: translateY(-50%);
    font-size: 0.7rem;
    color: #6B6560;
    pointer-events: none;
  }

  .rc-qty .rc-field {
    padding-right: 2.75rem;
    text-align: right;
  }

  .rc-suffix {
    position: absolute;
    top: 50%;
    right: 0.75rem;
    transform: translateY(-50%);
    font-size: 0.8125rem;
    color: #6B6560;
    pointer-events: none;
  }

  .rc-uc {
    text-align: right;
    font-size: 0.8125rem;
    color: #6B6560;
    font-variant-numeric: tabular-nums;
  }

  .rc-uc-btn {
    padding: 0.4rem 0.5rem;
    margin: -0.4rem -0.5rem;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: inherit;
    font: inherit;
    cursor: pointer;
    text-decoration: underline dotted #C9C3BA;
    text-underline-offset: 4px;
    transition: background-color 0.15s, color 0.15s;
  }

  .rc-uc-btn .rc-edit-mark {
    opacity: 0;
    font-size: 0.75rem;
    transition: opacity 0.15s;
  }

  .rc-uc-btn:hover,
  .rc-uc-btn:focus-visible {
    background: #EDF1E9;
    color: #415C43;
  }

  .rc-uc-btn:hover .rc-edit-mark,
  .rc-uc-btn:focus-visible .rc-edit-mark {
    opacity: 1;
  }

  .rc-cost {
    text-align: right;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
  }

  .rc-cost small {
    display: block;
    font-weight: 400;
    font-size: 0.6875rem;
    color: #6B6560;
  }

  /* Cormorant's default figures are old-style (the 0 reads as a small o); the total wants lining ones. */
  .rc-total {
    font-variant-numeric: lining-nums tabular-nums;
    font-feature-settings: "lnum", "tnum";
  }

  .rc-remove {
    width: 2.75rem;
    height: 2.75rem;
    border: 0;
    border-radius: 8px;
    background: transparent;
    font-size: 1.25rem;
    line-height: 1;
    color: #A39D95;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
  }

  .rc-remove:hover,
  .rc-remove:focus-visible {
    background: rgba(197, 57, 47, 0.08);
    color: #C5392F;
  }

  /* The add-row button is a lone "+": sized here, since the app's blanket button font-size outweighs utilities. */
  .v-matcha-front .rc-add {
    font-size: 1.75rem;
  }

  /* The big serif recipe name. Selector weight beats the app's blanket `input { font-size: max(16px, 1em) }`. */
  .v-matcha-front .rc-name {
    font-size: 2rem;
  }

  @media (min-width: 768px) {
    .v-matcha-front .rc-name {
      font-size: 2.5rem;
    }
  }

  /* The combobox list under a picker. */
  .rc-pop {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 6px);
    z-index: 30;
    min-width: 16rem;
    overflow: hidden;
    border: 1px solid #DEDFD3;
    border-radius: 8px;
    background: #FFFEFA;
    box-shadow: 0 18px 40px rgba(44, 44, 44, 0.12);
  }

  .rc-pop[hidden] {
    display: none;
  }

  .rc-options {
    max-height: 15.5rem;
    margin: 0;
    padding: 0.4rem;
    overflow: auto;
    list-style: none;
  }

  .rc-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    min-height: 2.5rem;
    padding: 0.5rem 0.65rem;
    border-radius: 6px;
    cursor: pointer;
  }

  .rc-option[aria-selected="true"] {
    background: #EDF1E9;
  }

  .rc-option[aria-disabled="true"] {
    color: #B0AAA2;
    cursor: default;
  }

  .rc-option small {
    font-size: 0.75rem;
    color: #6B6560;
    white-space: nowrap;
  }

  .rc-option[aria-disabled="true"] small {
    color: #B0AAA2;
  }

  .rc-option mark {
    background: transparent;
    color: #415C43;
    font-weight: 600;
  }

  .rc-no-match {
    padding: 0.75rem 0.65rem;
    font-size: 0.8125rem;
    color: #6B6560;
  }

  .rc-create {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    min-height: 3rem;
    padding: 0 1rem;
    border: 0;
    border-top: 1px solid #EAE7DF;
    background: #FBFAF4;
    color: #415C43;
    font-size: 0.9375rem;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
  }

  .rc-create[aria-selected="true"],
  .rc-create:hover {
    background: #EDF1E9;
  }

  @media (max-width: 767px) {
    .rc-head {
      display: none;
    }

    .rc-line {
      grid-template-columns: 7rem minmax(0, 1fr) 5.5rem;
      grid-template-areas: "pick pick remove" "qty uc cost";
      gap: 0.65rem 0.75rem;
      padding: 0.9rem 1rem;
    }

    .rc-pick {
      grid-area: pick;
    }

    .rc-qty {
      grid-area: qty;
    }

    .rc-qty .rc-field {
      padding: 0 2.25rem 0 0.75rem;
      text-align: left;
    }

    .rc-uc {
      grid-area: uc;
      text-align: left;
      white-space: nowrap;
    }

    .rc-uc:not([hidden])::before {
      content: "\00d7  ";
    }

    .rc-cost {
      grid-area: cost;
      justify-self: end;
      font-size: 1rem;
    }

    .rc-cost small {
      display: none;
    }

    .rc-x {
      grid-area: remove;
      justify-self: end;
    }
  }
}
