/* grocery-list.ftl-specific styles. Also loaded by splash.ftl, whose hero
   mockup reuses the real .grocery-item/.item-check markup. Depends on
   base.css (loaded first) for shared primitives like .icon-button and
   .add-item-form. */

.recipes-used-shortcut {
  display: inline-block;
  color: var(--accent);
  font-size: 0.9rem;
  text-decoration: none;
  margin: 0 0 1.5rem;
}
.recipes-used-shortcut:hover {
  text-decoration: underline;
}
/* Above the open category sheet (z-index 30), so "+" stays reachable while browsing a list. */
#groceryFab {
  align-items: flex-end;
  z-index: 31;
}
/* Side slide-over (base.css `dialog.slideover`). fitToKeyboard() in app.js fits it
   to the area above the on-screen keyboard; the "Added this time" list takes
   the remaining height and scrolls. */
#itemDialog .add-item-form {
  margin-bottom: 0;
}
#itemDialog .suggestions-dropdown-static {
  flex: 1 1 100%;
  margin: 0;
}
.aisle-picker { flex: 1 1 100%; display: flex; flex-direction: column; gap: 0.4rem; }
.aisle-picker-label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}
.aisle-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.aisle-chip {
  width: auto;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: capitalize;
  padding: 0.45rem 0.8rem;
  border-radius: 8px;
  border: 1px solid transparent;
  background: var(--track);
  color: var(--text);
  cursor: pointer;
}
.aisle-chip:hover { border-color: var(--accent); }
/* Auto's dashed outline marks it as "no explicit choice"; the predicted aisle
   is tinted so it's visible while Auto is selected. */
.aisle-chip-auto { border-style: dashed; border-color: var(--border); text-transform: none; }
.aisle-chip-predicted,
.aisle-chip-predicted:hover { background: #fdece0; border-color: #fdece0; color: #ad4c1e; }
.aisle-chip[aria-checked="true"] {
  background: var(--accent);
  border-color: var(--accent);
  border-style: solid;
  color: #fff;
}
.aisle-chip[aria-checked="true"]:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.add-item-actions { flex: 1 1 100%; display: flex; gap: 0.5rem; }
.add-item-actions button { flex: 1; width: auto; }
.added-this-time { margin-top: 1rem; flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.added-this-time h4 {
  margin: 0 0 0.4rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}
.added-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.6rem;
  background: var(--bg);
  border-radius: 8px;
  margin-bottom: 0.3rem;
}
.added-row-name { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.added-row .aisle-chip { font-size: 0.75rem; padding: 0.25rem 0.6rem; flex-shrink: 0; }
.list-actions {
  display: flex;
  gap: 0.625rem;
  margin: 0 0 1.5rem;
}
.pill-button {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  width: auto;
  flex-shrink: 0;
  height: 2.25rem;
  box-sizing: border-box;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 0.875rem 0 0.75rem;
  font-size: 0.8rem;
  font-weight: 500;
  font-family: inherit;
  white-space: nowrap;
  cursor: pointer;
}
/* Own background on hover/active: base.css's bare `button:hover` would otherwise
   paint the accent fill behind this button's text. */
.pill-button:hover {
  background: var(--track);
  border-color: var(--border);
  color: var(--text);
}
.pill-button:active {
  background: #efdfd1;
}
.pill-button svg {
  width: 0.9rem;
  height: 0.9rem;
  fill: currentColor;
  flex-shrink: 0;
}
.item-check-static {
  width: 1.15rem;
  flex-shrink: 0;
  text-align: center;
  color: var(--accent);
}
.grocery-item { padding: 0; position: relative; overflow: hidden; }
.grocery-item.removing { display: none; }
.grocery-item-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  background: var(--surface);
  position: relative;
  z-index: 1;
  touch-action: pan-y;
}
.item-check { display: flex; align-items: center; padding: 0.35rem; margin: -0.35rem; cursor: pointer; }
.grocery-item-checked .grocery-item-row { background: #fff7f1; }
.item-text { flex: 1; min-width: 0; }
.grocery-item-row { cursor: pointer; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; }
.grocery-item-row:has(.item-edit-btn) { padding-right: 0; }
/* Divider-separated tap zone: the rest of the row checks the item. */
.item-edit-btn {
  flex-shrink: 0;
  align-self: stretch;
  width: 2.75rem;
  margin: -0.4rem 0;
  display: grid;
  place-content: center;
  padding: 0;
  background: none;
  border: 0;
  border-left: 1px solid var(--border);
  border-radius: 0;
  color: var(--muted);
  cursor: pointer;
}
.item-edit-btn svg { width: 1.15rem; height: 1.15rem; fill: currentColor; }
.item-edit-btn:hover, .item-edit-btn:active { color: var(--accent); background: none; }
/* Checked items are done; nothing to edit. */
.grocery-item-checked .item-edit-btn { display: none; }
.grocery-item-checked .grocery-item-row:has(.item-edit-btn) { padding-right: 1.25rem; }
.checked-text { text-decoration: line-through; color: var(--muted); }
.grocery-item-pending .item-text { color: var(--muted); font-style: italic; }
.item-pending-badge { margin-left: auto; display: flex; align-items: center; flex-shrink: 0; }
.item-pending-badge .spinner { width: 0.85rem; height: 0.85rem; border-width: 2px; }
.item-sync-badge { margin-left: auto; display: flex; align-items: center; flex-shrink: 0; }
.item-sync-badge .sync-dot { width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--muted); flex-shrink: 0; }
.item-delete-btn {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 84px;
  background: #b3261e;
  color: #fff;
  border: none;
  font-size: 0.9rem;
  cursor: pointer;
}
.undo-toast {
  position: fixed;
  left: 50%;
  bottom: calc(1.5rem + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: #323232;
  color: #fff;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.9rem;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  width: max-content;
  max-width: calc(100vw - 2rem);
}
.undo-toast button {
  width: auto;
  background: transparent;
  border: none;
  color: #8ab4f8;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}
/* Opens upward (bottom: 100%) since #groceryFab is anchored near the bottom of
   the viewport - opening downward left it clipped under whatever space remained below. */
.suggestions-dropdown {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  margin-bottom: 0.25rem;
  max-height: 220px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(43, 33, 24, 0.3);
  z-index: 10;
}
.suggestions-dropdown[hidden] {
  display: none;
}
.suggestion-option {
  padding: 0.6rem 0.75rem;
  font-size: 0.95rem;
  color: var(--text);
  cursor: pointer;
}
.suggestion-aisle {
  float: right;
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: capitalize;
  padding-top: 0.15rem;
}
.suggestion-option:hover,
.suggestion-option:active {
  background: var(--bg);
}
/* Same suggestion-list markup as the add-item autocomplete, but positioned
   inline below its input instead of anchored above a viewport-bottom FAB. */
.suggestions-dropdown-static {
  position: static;
  margin: 0 0 0.75rem;
  box-shadow: none;
}
.meal-tags-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 0.75rem;
}
.meal-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--track);
  color: var(--text);
  border-radius: 6px;
  padding: 0.2rem 0.5rem 0.2rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 500;
}
.meal-tag-remove {
  background: none;
  border: none;
  color: inherit;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.15rem;
}
.dialog-hint {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.4;
  margin: 0 0 0.75rem;
}

/* SECTION: Category panels (one per category; at most one open) */
a.pill-button { text-decoration: none; }
/* Each category is one compact row (the index); its items live in a slide-over
   sheet that reuses the add/edit dialogs' side-panel look. `.open` marks the list the
   page acts on and is server-rendered; `.showing` is the sheet actually on screen. */
.panel {
  margin-bottom: 0.6rem;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface);
}
.panel-head {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  padding: 0.8rem 1rem;
  background: none;
  border: 0;
  border-radius: 15px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.panel-head:hover { background: none; }
.panel-head:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.panel .pmain { flex: 1; min-width: 0; }
.panel .pname { display: block; font-weight: 700; font-size: 1.02rem; overflow-wrap: anywhere; }
.panel .pcount, .panel .sheet-count { font-size: 0.78rem; color: var(--muted); white-space: nowrap; }
.panel .peek { display: block; color: var(--muted); font-size: 0.82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.panel .go { color: var(--muted); font-size: 1.3rem; line-height: 1; }
/* A list shared with you: an accent edge, a tinted surface and a visible dismiss button,
   under its own "Shared with you" heading, so it never reads as one of your categories. */
.shared-heading { margin-top: 1.25rem; }
.panel-shared {
  position: relative;
  border-left: 4px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, var(--surface));
}
.panel-shared .panel-head { padding-right: 3.2rem; }
.panel-dismiss {
  position: absolute;
  top: 0.55rem;
  right: 0.5rem;
  width: 1.9rem;
  height: 1.9rem;
  padding: 0;
  display: grid;
  place-items: center;
  background: none;
  border: 0;
  border-radius: 50%;
  color: var(--muted);
  cursor: pointer;
}
.panel-dismiss:hover { background: var(--bg); color: #c0392b; }
.panel-dismiss svg { width: 1.1rem; height: 1.1rem; fill: currentColor; }
.panel-more {
  width: 2rem;
  height: 2rem;
  padding: 0;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: none;
  border: 0;
  border-radius: 50%;
  color: var(--muted);
  cursor: pointer;
}
.panel-more:hover { background: var(--bg); color: var(--accent); }
.panel-more svg { width: 1.2rem; height: 1.2rem; fill: currentColor; }
/* Dims the page behind the sheet on screens wider than the sheet; a click on it closes. */
.panel::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 29;
  background: rgba(43, 33, 24, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.38s;
}
.panel.showing::before { opacity: 1; pointer-events: auto; }
/* A closed sheet is visibility:hidden (after it finishes sliding out) so its contents
   can't be tapped or tabbed to. */
.sheet {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: 30;
  box-sizing: border-box;
  width: 100%;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  padding: calc(1.25rem + env(safe-area-inset-top, 0px)) 1rem 0;
  background: var(--surface);
  border-radius: 18px 0 0 18px;
  box-shadow: -10px 0 30px rgba(43, 33, 24, 0.25);
  transform: translateX(100%);
  visibility: hidden;
  transition: transform 0.38s cubic-bezier(0.2, 0.8, 0.2, 1), visibility 0s 0.38s;
}
.panel.showing .sheet { transform: none; visibility: visible; transition-delay: 0s; }
@media (max-width: 440px) {
  .sheet { border-radius: 0; }
}
.sheet:focus { outline: none; }
.sheet-head { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.9rem; flex-shrink: 0; }
.sheet-title { margin: 0; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.sheet-back {
  width: 2rem;
  height: 2rem;
  padding: 0;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  border: 0;
  border-radius: 50%;
  background: var(--bg);
  color: var(--text);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}
.sheet-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-bottom: calc(5.5rem + env(safe-area-inset-bottom, 0px)); /* clears the floating + */
}
body.sheet-open { overflow: hidden; }
@media (prefers-reduced-motion: reduce) {
  .panel::before, .sheet { transition-duration: 0.01ms; }
}
.panel .empty-state { margin: 0.2rem 0.2rem 0.6rem; }
.panel .meal-tags-row { margin-bottom: 0.6rem; }
.panel .recipes-used-shortcut { margin-bottom: 0.6rem; }
.newpanel {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  padding: 0.85rem;
  border-radius: 16px;
  border: 1px dashed var(--border);
  background: none;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 500;
}
.newpanel:hover { background: none; border-color: var(--accent); color: var(--accent); }
/* The (⋯) menu. Fixed to the viewport (positioned from the button's rect in app.js) so a
   panel's overflow:hidden can't clip it. */
.panel-menu {
  position: fixed;
  z-index: 40;
  min-width: 13rem;
  max-height: calc(100vh - 16px);
  overflow-y: auto;
  padding: 0.3rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(43, 33, 24, 0.22);
}
.panel-menu-item {
  display: block;
  width: 100%;
  padding: 0.6rem 0.7rem;
  background: none;
  border: 0;
  border-radius: 8px;
  color: var(--text);
  font-size: 0.9rem;
  text-align: left;
}
.panel-menu-item:hover, .panel-menu-item:focus-visible { background: var(--bg); }
/* Not ".danger": base.css's button.danger would box the item like a destructive button. */
.panel-menu-item.is-danger { color: #c0392b; }

.added-row-list { color: var(--muted); font-size: 0.75rem; margin-left: 0.25rem; }
#newListDialog .dest-picker { flex: 0 0 auto; margin-bottom: 0.8rem; }
/* The slide-over is a flex column; keep the info line and buttons at their natural height. */
#newListDialog .dialog-hint { flex: 0 0 auto; margin: 0 0 1rem; }
#newListDialog .add-item-actions { flex: 0 0 auto; }
