/* Shop: the lists index, a new list, the list page (UX pass 2 §4, WP3). Shared components
   (buttons, rows, .seg, .field, notices, pills, the ⋯ menu, .more) are in app.css; this
   sheet only lays them out. Existing tokens only, so light and dark come free. The
   status pills (pill-list-*, pill-manual, pill-unmapped, pill-sent, pill-to-send) are
   coloured in app.css through their tones. */

/* ---- The index: the lists as divided rows on one surface. ---- */
.shop-rows {
  margin: 0 0 var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.shop-rows .row-link {
  padding: var(--space-2) var(--space-4);
}

.shop-finished .shop-rows {
  margin-top: var(--space-2);
}

/* A fold whose summary carries a count or hint ("Already have (2)", "Amount (optional)",
   "Done lists (3)"): the hint follows the words, the chevron stays on the right. */
:is(.shop-card, .shop-finished, .shop-new-more) .more > summary,
.shop-finished > summary {
  justify-content: flex-start;
  gap: var(--space-2);
}

:is(.shop-card, .shop-finished, .shop-new-more) .more > summary::after,
.shop-finished > summary::after {
  margin-left: auto;
}

/* ---- A new list. ---- */
.shop-generate {
  margin: 0 0 var(--space-4);
}

.shop-sessions {
  min-width: 0;
  margin: 0 0 var(--space-4);
  padding: 0;
  border: 0;
}

.shop-sessions legend {
  margin-bottom: var(--space-2);
  padding: 0;
  font-weight: 600;
}

.shop-sessions .notice {
  margin-bottom: var(--space-2);
}

.shop-sessions .option-meta {
  white-space: nowrap;
}

.shop-range {
  margin-bottom: var(--space-3);
}

.shop-optional {
  margin: 0 0 var(--space-4);
}

/* ---- The list page. ---- */

/* The ⋯ menu's refresh form: the button, a quiet line, the optional-ingredients chip. */
.shop-head .menu-panel {
  min-width: 17rem;
}

.shop-head .menu-panel .chip-input {
  margin: 0 var(--space-3) var(--space-2);
}

.shop-reopen {
  border-top: 1px solid var(--border);
  padding-top: var(--space-1);
}

/* The side column: summary, notices, the meals it is for, the Walmart card. */
.shop-aside {
  margin-bottom: var(--space-5);
}

.shop-aside > * + * {
  margin-top: var(--space-3);
}

.shop-done {
  margin: 0;
  font-weight: 600;
}

.shop-summary > * + * {
  margin-top: var(--space-3);
}

.shop-summary-counts {
  margin: 0;
  font-size: var(--text-lg);
}

.shop-sent-times {
  font-size: var(--text-sm);
}

.shop-missing,
.shop-changed {
  overflow-wrap: anywhere;
}

/* The list's days, then the meals it is for, one row each. */
.shop-span {
  margin: 0 0 var(--space-2);
}

.shop-for {
  margin: 0 0 var(--space-4);
  overflow-wrap: anywhere;
}

/* The Walmart card: its heading, the two cart buttons, the setup toggle. */
.shop-walmart h2 {
  margin: 0 0 var(--space-2);
}

.shop-walmart .stack-actions > * {
  width: 100%;
}

/* "3 items need a product" / "Nothing new to send": says why there is no button. */
#open-cart.is-inert {
  display: flex;
  align-items: center;
  min-height: var(--tap);
}

.shop-send-all {
  margin: var(--space-2) 0 0;
  font-size: var(--text-sm);
}

.shop-walmart-setup {
  margin-top: var(--space-2);
}

.shop-hint {
  margin: 0 0 var(--space-2);
  font-size: var(--text-sm);
}

/* The lines. */
.shop-section {
  margin-bottom: var(--space-5);
}

.shop-section > h2,
.shop-group-head {
  margin: 0;
  padding-bottom: var(--space-1);
  border-bottom: 2px solid var(--border);
}

/* One line: a two-line row (name and pills, then the amount and what it is for) with the
   toggle at the end; an error or the "Choose Walmart item" fold spans the row below. A
   200-character name wraps instead of widening the page at 360 px. */
.shop-line {
  min-width: 0;
  overflow-wrap: anywhere;
}

.shop-line > .row-end {
  grid-row: 1;
}

.shop-line > :is(.shop-line-error, .shop-map) {
  grid-column: 1 / -1;
}

.shop-line-main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-2);
  min-width: 0;
}

.shop-line-name {
  font-weight: 600;
  min-width: 0;
  overflow-wrap: anywhere;
}

.shop-line-meta {
  flex: 1 1 100%;
  min-width: 0;
  font-size: var(--text-sm);
  color: var(--text-subtle);
  overflow-wrap: anywhere;
}

.shop-line-error {
  margin: 0;
  font-size: var(--text-sm);
}

/* Have | Need and Buy | Skip: narrower than the shared .seg so a phone keeps room for the
   name; ✕ beside the toggle on an added line. */
.shop-toggle {
  margin: 0;
}

.shop-toggle > button {
  min-width: 4.25rem;
  padding: 0 var(--space-2);
}

.shop-remove {
  margin: 0;
}

/* A skipped line on a final, carted or done list stays in its aisle, dimmed and struck
   through, with its reason under the name (M9c). The reason also shows on a folded
   "Already have" line while the list is open. */
.shop-card:not(.status-draft, .status-triage) .shop-line.decision-skip .shop-line-name {
  color: var(--muted);
  text-decoration: line-through;
}

.shop-line-reason {
  flex: 1 1 100%;
  min-width: 0;
  font-size: var(--text-sm);
  color: var(--text-subtle);
  font-style: italic;
}

.pill-skip {
  background: var(--border);
  color: var(--text);
  cursor: help;
}

/* "Add something else": the name and [Add] on one row; the amount folds away. */
.shop-add {
  margin-top: var(--space-4);
}

.shop-add > label {
  display: block;
  margin-bottom: var(--space-1);
  font-weight: 600;
}

.shop-add .field {
  margin-bottom: var(--space-2);
}

/* Aisles: sentence-case heads that stay in view while the aisle scrolls. */
.shop-group {
  margin-bottom: var(--space-4);
}

.shop-group-head {
  position: sticky;
  top: 0;
  z-index: 1;
  padding-top: var(--space-2);
  background: var(--bg);
  font-size: var(--text-base);
}

/* "Set up Walmart items": the unmapped lines' pill and form show only while it is open.
   Without :has (old browsers) they simply stay visible, as before the toggle. */
.shop-card:not(:has(.shop-walmart-setup[open])) :is(.shop-map, .pill-unmapped) {
  display: none;
}

.shop-map-form {
  margin-bottom: var(--space-2);
}

.shop-map-form .field {
  margin-bottom: 0;
}

.shop-actions form {
  margin: 0;
}

@media (min-width: 40rem) {
  .shop-map-form > button {
    grid-column: 1 / -1;
    justify-self: start;
  }

  .shop-walmart .stack-actions {
    flex-direction: column;
  }
}

/* Desktop: the lines beside a sticky side column (summary, notices, Walmart card). */
@media (min-width: 64rem) {
  .shop-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 20rem;
    grid-template-areas:
      "head head"
      "alert alert"
      "main aside";
    column-gap: var(--space-6);
    align-items: start;
  }

  .shop-head {
    grid-area: head;
  }

  .shop-card > .alert {
    grid-area: alert;
    margin-bottom: var(--space-4);
  }

  .shop-main {
    grid-area: main;
  }

  .shop-aside {
    grid-area: aside;
    position: sticky;
    top: var(--space-5);
    margin-bottom: 0;
  }
}

/* On a desktop the list index keeps the reading width: the pill stays near the title. */
@media (min-width: 64rem) {
  .shop-rows {
    max-width: var(--content-reading);
  }
}
