/*
 * 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-sections + .group-list__note + .group-new { margin-top: var(--space-6); }
  .group-new + .empty-state { margin-top: var(--space-5); }
  .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); }

  .entry__summary {
    display: flex;
    align-items: center;
    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); }
  .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; }
  .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 { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2); padding: var(--space-3) var(--space-4); }
  .archived-definitions__row .entry__name { color: var(--muted); }
  .archived-definitions__actions { display: flex; gap: var(--space-1); }
  .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; }
}
