/* The shopping page, in the video apps' list layout (theme.css; guide:
   shopping/web/STYLE.md). Measurements are the video apps' own. */

* { box-sizing: border-box; }
body { padding: 12px 16px 40px; }
header, main { max-width: 900px; margin: 0 auto; }

header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.brand {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--accent);
}
h1 { font: 600 15px var(--font); margin: 0; }
h2 {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 24px 0 6px;
}
p { color: var(--muted); }
a { color: var(--accent); }
.error { color: var(--danger); }

.count {
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0;
  padding: 1px 7px;
  margin-left: 6px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
}

/* -- controls ------------------------------------------------------------------------ */

button {
  font: inherit;
  font-size: 13px;
  color: var(--muted);
  background: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 5px 10px;
  cursor: pointer;
}
button:hover:not(:disabled) { color: var(--text); background: var(--raised); }
button[aria-pressed="true"] { color: var(--text); background: var(--raised); border-color: var(--accent); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.primary:hover:not(:disabled) { filter: brightness(1.06); background: var(--accent); color: var(--accent-ink); }
button.quiet { border-color: transparent; }
button:disabled { opacity: .4; cursor: default; }
button:focus-visible, input:focus-visible, summary:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
input[type="file"] { font: inherit; font-size: 13px; color: var(--muted); max-width: 100%; }

/* -- what the household buys ------------------------------------------------------------- */

ul.items {
  list-style: none;
  padding: 0;
  margin: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
li.item {
  display: grid;
  grid-template-columns: 48px 1fr;
  grid-template-areas: "pic what" "pic marks";
  gap: 6px 12px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
}
li.item:first-child { border-top: 0; }
li.item > img, li.item > .no-image {
  grid-area: pic;
  width: 48px;
  height: 48px;
  object-fit: contain;
  border-radius: var(--radius);
  background: var(--text); /* product photos are cut out on white */
}
li.item > .no-image { background: var(--raised); }
li.item .what { grid-area: what; min-width: 0; }
li.item .name { font-weight: 600; overflow-wrap: anywhere; }
li.item .size { color: var(--muted); font-weight: 400; }
li.item .meta { color: var(--muted); font-size: 13px; }
li.item .marks { grid-area: marks; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
li.item .saving { font-size: 12px; color: var(--muted); }

/* A product with its own rhythm, under its kind's card; and the kind's
   products, listed when opened. */
li.item.nested { margin-left: 28px; border-left: 2px solid var(--line); border-top-style: dashed; }
li.kind-heading { padding: 10px 12px 6px; border-top: 1px solid var(--line); font-weight: 600; overflow-wrap: anywhere; }
li.kind-heading:first-child { border-top: 0; }
li.kind-heading .size { color: var(--muted); font-weight: 400; font-size: 13px; }
li.kind-heading + li.item.nested { border-top-style: none; }
li.item .members { margin-top: 4px; font-size: 13px; }
li.item .members > summary { font-size: 12px; font-weight: 400; letter-spacing: 0; text-transform: none; }
li.item .members ul { margin: 4px 0 0; padding-left: 16px; color: var(--muted); }
li.item .members li { overflow-wrap: anywhere; }
li.item .marks .error { font-size: 12px; }

/* A stock state's colour supplements its words (STYLE.md). */
button[data-state="in"][aria-pressed="true"] { border-color: var(--in-stock); }
button[data-state="low"][aria-pressed="true"] { border-color: var(--running-low); }
button[data-state="out"][aria-pressed="true"] { border-color: var(--out); }
button[data-state="skip"][aria-pressed="true"] { border-color: var(--muted); }

/* -- uploads and settings ---------------------------------------------------------------- */

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
th, td { text-align: left; padding: 8px 12px; border-top: 1px solid var(--line); }
/* Only who uploaded may break anywhere -- an address is one long word that
   would push the table wider than a phone; headings and buttons never break. */
td:nth-child(4) { overflow-wrap: anywhere; }
@media (max-width: 420px) { th, td { padding: 8px 6px; } }  /* five columns in a phone's width */
th { color: var(--muted); font-size: 12px; font-weight: 600; border-top: 0; }
td:nth-child(2) { text-align: right; font-family: var(--mono); font-size: 13px; }

/* A voided upload: muted, "voided" and Restore under its shop. */
tr.voided > td { color: var(--muted); }
div.shop { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
div.shop .voided { font-size: 12px; }
label.show-voided { display: flex; align-items: center; gap: 8px; min-height: 44px; font-size: 14px; color: var(--muted); }
label.show-voided input { width: 20px; height: 20px; margin: 0; }

/* An upload's orders, under its row: each a <details>, its lines a list. */
tr.orders > td, tr.restore-failed > td { padding: 4px 12px 12px; }
details.order { margin-top: 8px; }
details.order > summary { font-size: 13px; font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--text); }
ul.lines { list-style: none; margin: 4px 0 0; padding: 0; font-size: 13px; }
ul.lines li { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; border-top: 1px solid var(--line); }
ul.lines .line-name { overflow-wrap: anywhere; min-width: 0; }
ul.lines .line-paid { font-family: var(--mono); white-space: nowrap; color: var(--muted); }
ul.lines li.not-bought { color: var(--muted); }
td button { padding: 3px 8px; white-space: nowrap; }

/* -- spending ------------------------------------------------------------------------------ */

div.month { display: flex; align-items: center; gap: 8px; }
div.month button { min-width: 44px; min-height: 44px; font-size: 18px; }
.spending input[type="text"], .spending input[type="number"], .spending select {
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 8px;
  min-height: 36px;
  min-width: 0;
}
.spending input:focus-visible, .spending select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.spending ::placeholder { color: var(--faint); }
/* A category's target and how far through it the month is: the bar is
   amber past its target, beside words that say so. */
table.budget-table td:nth-child(3) input { width: 96px; }
td.budget { font-size: 12px; color: var(--muted); overflow-wrap: normal; }  /* breaks between words, not in a sum */
span.meter { display: block; height: 6px; margin-bottom: 4px; background: var(--raised); border-radius: 3px; overflow: hidden; }
span.meter .bar { display: block; height: 100%; background: var(--done); }
span.meter .bar.over { background: var(--working); }
@media (max-width: 420px) { table.budget-table td:nth-child(3) input { width: 72px; } }
/* An order's tags, then each line's: its name and price, its tags under them. */
div.order-tag { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-size: 13px; color: var(--muted); }
.spending ul.lines li { flex-direction: column; gap: 4px; }
.spending ul.lines div.line { display: flex; justify-content: space-between; gap: 12px; }
div.tag { display: flex; flex-wrap: wrap; gap: 6px; }
div.tag input[type="text"] { flex: 1 1 64px; max-width: 240px; }
div.tag select { flex: 0 1 auto; }
div.tag p.error { flex-basis: 100%; margin: 0; }
span.tag-words { font-size: 12px; color: var(--muted); }
.spending h3 { font-size: 13px; color: var(--muted); margin: 16px 0 4px; }

details { margin-top: 16px; }
details > summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
}
details[open] > summary { margin-bottom: 6px; }
.signed-in { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 12px 0 0; }

/* -- on a phone: a deck of cards ----------------------------------------------------------- */

/* The sections as tabs, across the top. */
/* Each tab's count sits under its label, and a column may shrink below its
   content (minmax(0, 1fr)), so a hundred-odd count still fits at 320px
   (Codex, #20 review). */
.tabs { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; margin: 16px 0 10px; }
button.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 0;
  min-height: 44px;
  padding: 6px 2px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}
button.tab .count { margin-left: 0; padding: 0 5px; }
/* Six tabs on the narrowest phones: each label on one line, whole. */
@media (max-width: 380px) {
  button.tab { font-size: 11px; letter-spacing: 0; padding: 6px 0; }
}
button.tab[aria-selected="true"] { color: var(--text); background: var(--raised); border-color: var(--accent); }

/* One card a screen, swiped across: the browser's scrolling, snapped. */
.deck-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.deck-nav .position { font-family: var(--mono); font-size: 13px; color: var(--muted); }
.deck-nav button { font-size: 20px; line-height: 1; min-width: 44px; min-height: 44px; }
ul.deck {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}
ul.deck::-webkit-scrollbar { display: none; }
li.item.card {
  flex: 0 0 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: calc(100svh - 210px);
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
li.item.card > img, li.item.card > .no-image {
  align-self: center;
  width: min(240px, 60vw);
  height: min(240px, 60vw);
  object-fit: contain;
  border-radius: var(--radius);
  background: var(--text);
}
li.item.card > .no-image { background: var(--raised); }
li.item.card .what { flex: 1; min-width: 0; }
li.item.card .name { font-size: 20px; line-height: 1.3; font-weight: 600; overflow-wrap: anywhere; }
li.item.card .size { color: var(--muted); font-weight: 400; }
li.item.card .meta { color: var(--muted); font-size: 15px; margin-top: 6px; }
li.item.card .members { font-size: 14px; }
li.item.card .marks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
li.item.card .marks button { font-size: 17px; min-height: 64px; color: var(--text); }
/* "skip a week" is the odd one out: its own row, under the three. */
li.item.card .marks button[data-state="skip"] { grid-column: 1 / -1; min-height: 48px; font-size: 15px; color: var(--muted); }
li.item.card .marks .saving, li.item.card .marks .error { grid-column: 1 / -1; text-align: center; font-size: 13px; min-height: 1.45em; }

/* -- meals ----------------------------------------------------------------------------- */

/* The weekend as a calendar: two days side by side, each a breakfast, a
   lunch and a dinner; each meal a button listing its dishes, each with a
   3px rule on its left in its ingredients' colour -- the words say it too. */
.meals .plan { color: var(--text); margin: 0 0 10px; overflow-wrap: anywhere; }
/* A day's heading and meals share the calendar's rows (subgrid), so lunch
   sits beside lunch however long either day's dishes or heading. */
.calendar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(4, auto);
  column-gap: 10px; max-width: 900px; }
.calendar .day { display: grid; grid-row: span 4; grid-template-rows: subgrid; row-gap: 6px; min-width: 0; }
.calendar h3 { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text); margin: 0 0 2px;
  align-self: end; }
.calendar .day.past h3 { color: var(--muted); }
.calendar .today { color: var(--accent); }
button.slot { display: flex; flex-direction: column; align-items: stretch; gap: 6px; text-align: left; min-height: 64px;
  padding: 10px 12px; background: var(--panel); color: var(--text); font-size: 14px; }
.calendar .day.past button.slot { color: var(--muted); }
button.slot .label { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
button.slot .empty { color: var(--muted); }
button.slot .dishes { display: flex; flex-direction: column; gap: 6px; }
.dish { display: flex; flex-direction: column; padding-left: 8px; border-left: 3px solid var(--line); overflow-wrap: anywhere; }
.dish .name { font-weight: 600; }
.dish .needs, .option .needs { font-size: 12px; color: var(--muted); }
.dish.have, .option.have { border-left-color: var(--in-stock); }
.dish.check, .option.check { border-left-color: var(--running-low); }
.dish.need, .option.need { border-left-color: var(--out); }

/* A meal's choice: a modal list of the recipes, a checkbox each, 48px
   rows; the whole screen on a phone. */
dialog.pick { width: min(520px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 0; color: var(--text);
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
dialog.pick::backdrop { background: rgb(0 0 0 / .6); }
dialog.pick form { padding: 14px 16px 16px; }
dialog.pick h3 { font-size: 15px; font-weight: 600; margin: 0 0 10px; }
dialog.pick .options { display: flex; flex-direction: column; }
dialog.pick .options + .options { margin-top: 12px; }
dialog.pick h4 { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
  margin: 0 0 2px; }
dialog.pick details { margin-top: 10px; }
dialog.pick details > summary { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
  padding: 13px 0; cursor: pointer; }
.option { display: flex; gap: 12px; align-items: center; min-height: 48px; padding: 6px 0 6px 10px; border-left: 3px solid var(--line);
  border-bottom: 1px solid var(--line); cursor: pointer; }
.option input { width: 20px; height: 20px; flex: none; accent-color: var(--accent); margin: 0; }
.option .what { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
dialog.pick .saving, dialog.pick .error { min-height: 1.45em; margin: 10px 0 0; font-size: 13px; }
dialog.pick .saving { color: var(--muted); }
dialog.pick .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 10px; }
dialog.pick .actions button { min-height: 44px; min-width: 88px; font-size: 15px; }
@media (max-width: 600px) {
  .calendar { column-gap: 8px; }
  button.slot { padding: 8px 10px; }
  dialog.pick { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border: 0; border-radius: 0; }
  dialog.pick form { padding: 16px; }
}
