/*
 * Entries: groups, saved meals and what's added to a list. The same compact rows
 * as the Shopping list, with a mint badge where the check would be. Each
 * row opens to its own panel.
 */
@layer components {
  .group-form [hidden] { display: none; }

  .entry { padding-inline: var(--space-1) var(--space-2); }
  .entry:has(> .entry__menu) { display: flex; align-items: flex-start; padding-right: var(--space-1); }
  .entry > .entry__body { flex: 1; min-width: 0; }
  .entry[hidden] { display: none; } /* filtered out by a search: beats the flex above */
  .entry__menu { margin-top: 8px; }
  .entry + .entry { border-top: 1px solid var(--line); }

  /* Badge, name, chevron (and the row's menu, beside it). The name has all the width between them; anything else
     (a group's count, a meal's summary) goes underneath. Badge and chevron sit on the first line, as the menu does, however tall the row. */
  .entry__summary {
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
    min-height: 60px;
    list-style: none;
    cursor: pointer;
  }
  .entry__summary::-webkit-details-marker { display: none; }
  .entry__body[open] .shopping-item__more svg { transform: rotate(90deg); }

  .entry__badge { display: grid; place-items: center; flex: none; width: var(--touch); margin-top: 15px; }
  .entry__summary > .shopping-item__more { flex: none; margin-top: 14px; }
  .entry__badge svg {
    width: 30px;
    height: 30px;
    padding: 6px;
    border-radius: 50%;
    background: var(--mint-soft);
    color: var(--leaf);
  }

  .entry__text { display: grid; flex: 1; min-width: 0; padding-block: var(--space-2); }
  .entry__name { font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; }
  .entry__text > .shopping-item__quantity { justify-self: start; margin-block: var(--space-1); }
  .entry__when { color: var(--muted); font-size: var(--text-sm); font-weight: 600; }

  .entry__panel {
    display: grid;
    gap: var(--space-4);
    padding: var(--space-1) var(--space-2) var(--space-5) calc(var(--touch) + var(--space-1));
  }
  @media (max-width: 559px) { .entry__panel { padding-left: var(--space-2); } }

  /* Groups under sections: a small heading that collapses, then the usual rows. */
  .group-tools { display: flex; flex-wrap: wrap; align-items: start; gap: var(--space-2) var(--space-3); margin-bottom: var(--space-4); }
  .group-tools__search { flex: 1 1 16rem; }
  .group-tools__new > summary { list-style: none; }
  .group-tools__new > summary::-webkit-details-marker { display: none; }
  .group-tools__new[open] > summary { display: none; }
  .group-tools__form { display: flex; gap: var(--space-2); }
  .group-tools__form .input { width: 14rem; max-width: 100%; }

  .group-section { position: relative; margin-bottom: var(--space-5); }
  .group-section[hidden] { display: none; }
  .group-section__heading {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    min-height: var(--touch);
    margin: 0 calc(var(--touch) + var(--space-2)) var(--space-1) var(--space-1);
    color: var(--ink);
    font-weight: 800;
    list-style: none;
    cursor: pointer;
  }
  .group-section__heading::-webkit-details-marker { display: none; }
  .group-section__chevron { flex: none; width: 18px; height: 18px; color: var(--muted); transform: rotate(-90deg); transition: transform 160ms ease; }
  .group-section__body[open] .group-section__chevron { transform: none; }

  /* Archived groups or meals: collapsed at the end of the page, to restore or delete. */
  .archived-definitions { margin: var(--space-5) 0; }
  .archived-definitions[open] .group-section__chevron { transform: none; }
  .archived-definitions__note { margin: 0 0 var(--space-2) var(--space-1); color: var(--muted); font-size: var(--text-sm); }
  .archived-definitions__row { padding: var(--space-3) var(--space-4); }
  .archived-definitions__row .entry__name { color: var(--muted); }
  .archived-definitions__actions { display: flex; gap: var(--space-1); }
  /* A phone has no room for both buttons beside a name: they stack, still on the right, on every row alike. */
  @media (max-width: 479.98px) { .archived-definitions__actions { flex-direction: column; align-items: stretch; } }
  .group-section__count { color: var(--muted); font-weight: 700; }
  .group-section > .group-section__menu { position: absolute; top: 0; right: 0; }
  .group-section__empty {
    margin: 0;
    padding: var(--space-4);
    border: 1px dashed var(--line);
    border-radius: var(--radius-lg);
    color: var(--muted);
    font-size: var(--text-sm);
    font-weight: 600;
  }

  /* A row's ••• stays out of the way until the row is hovered or focused, where
     hovering is a thing; on touch it's always there, quietly. */
  @media (hover: hover) {
    .entry__menu:not([open]) .row-menu__toggle { opacity: 0; transition: opacity 120ms ease; }
    .entry:hover .entry__menu .row-menu__toggle,
    .entry:focus-within .entry__menu .row-menu__toggle { opacity: 1; }
  }
  @media (hover: none) { .entry__menu .row-menu__toggle { opacity: .6; } }

  .group-list__note { margin: var(--space-3) var(--space-2) 0; color: var(--muted); font-size: var(--text-sm); font-weight: 600; }

  /* The small mark beside a group's item's name on the Shopping list. */
  .shopping-item__group { display: inline-grid; vertical-align: -2px; margin-left: var(--space-2); color: var(--leaf); }
  .shopping-item__group svg { width: 15px; height: 15px; stroke-width: 2.4; }
}

/*
 * What a group or meal contains, read-only (compositions/_contents): items with
 * their amounts, and included groups or meals that open in place, one level at
 * a time. Depth shows as a rule on the left, never as ever-growing indents.
 */
@layer components {
  .contents-panel { display: grid; gap: var(--space-2); }
  .contents-panel__heading { margin: 0; color: var(--muted); font-size: var(--text-sm); font-weight: 800; }
  .contents-panel__actions { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-2); }

  .contents { display: grid; margin: 0; padding: 0; list-style: none; }
  .contents__line { display: flex; align-items: baseline; gap: var(--space-3); min-height: 40px; padding-block: var(--space-2); }
  .contents__line + .contents__line { border-top: 1px solid var(--line); }
  .contents__line--nested { display: block; padding-block: 0; }
  .contents__name { flex: 1; min-width: 0; font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; }
  .contents__amount { flex: none; color: var(--ink); font-weight: 800; font-variant-numeric: tabular-nums; }

  .contents__summary { display: flex; align-items: center; gap: var(--space-2); min-height: var(--touch); padding-block: var(--space-1); list-style: none; cursor: pointer; }
  .contents__summary::-webkit-details-marker { display: none; }
  .contents__chevron { flex: none; width: 18px; height: 18px; color: var(--muted); transition: transform 120ms ease; }
  .contents__nested[open] > .contents__summary .contents__chevron { transform: rotate(90deg); }
  .contents__badge { display: grid; place-items: center; flex: none; }
  .contents__badge svg { width: 26px; height: 26px; padding: 5px; border-radius: 50%; background: var(--mint-soft); color: var(--leaf); }
  .contents__text { display: grid; flex: 1; min-width: 0; }
  .contents__meta { color: var(--muted); font-size: var(--text-sm); font-weight: 600; }
  .contents__times { flex: none; padding: 2px var(--space-2); border-radius: var(--radius-pill); background: var(--mint-soft); color: var(--leaf); font-size: var(--text-sm); font-weight: 800; }

  .contents__frame { display: block; margin: 0 0 var(--space-2) 9px; padding-left: var(--space-3); border-left: 2px solid var(--line); }
  .contents-panel > .contents__frame { margin: 0; padding: 0; border: 0; }
  .contents__frame[busy] { opacity: .6; }
  .contents__fallback { display: inline-block; padding-block: var(--space-2); font-size: var(--text-sm); font-weight: 800; }
  @media (max-width: 559px) { .contents__frame { padding-left: var(--space-2); } }

  .hint-disclosure { color: var(--muted); font-size: var(--text-sm); font-weight: 600; }
  .hint-disclosure__summary { display: inline-flex; align-items: center; gap: var(--space-1); min-height: 32px; color: var(--leaf); font-weight: 800; list-style: none; cursor: pointer; }
  .hint-disclosure__summary::-webkit-details-marker { display: none; }
  .hint-disclosure__summary svg { width: 16px; height: 16px; }
  .hint-disclosure__body { display: grid; gap: var(--space-1); margin-top: var(--space-1); }
  .hint-disclosure__body p { margin: 0; }
}
