/* ---------- Layout ---------- */

.page-shell {
  display: block;
}

/* Wraps the desktop sidebar + #app. Below 860px it's a plain block (sidebar hidden, unchanged layout);
   at 860px (the same breakpoint .nav-extra/.desktop-icon already key off, see below) it becomes the
   two-column desktop layout. */
.layout-shell {
  display: block;
}

main#app {
  max-width: 680px;
  margin: 0 auto;
  padding: 16px 16px 32px;
  min-width: 0;
}

.side-rail {
  display: none;
}

.app-sidebar {
  display: none;
}

h1, h2, h3 { margin: 0; }

.h1 { font-size: 22px; font-weight: 500; }
.h2 { font-size: 18px; font-weight: 500; }
.h3 { font-size: 16px; font-weight: 500; }
.ui-label {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.price { font-variant-numeric: tabular-nums; }

/* ---------- Discover banner ---------- */
/* Static first-party message, gradient-only for now (no photo until image storage exists, #13).
   Slim on purpose on every width — a space-hungry hero was considered and rejected so the mobile
   category rail right below it keeps its room. */
.discover-banner {
  display: flex;
  align-items: center;
  min-height: 64px;
  margin: 0 0 14px;
  padding: 18px 20px;
  border-radius: var(--radius-lg);
  background: var(--banner-gradient);
  text-decoration: none;
}

.discover-banner p {
  margin: 0;
  color: var(--banner-title);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.45;
}

/* ---------- Category rail ---------- */

.category-rail {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  overflow: hidden;
  padding: 4px 2px 12px;
  margin: 4px 0 2px;
}

.category-more-icon { background: var(--surface-2); color: var(--text-muted); }

.category-tile {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 64px;
  border: none;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
}

.category-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}

.category-tile.is-empty .category-tile-label { color: var(--text-muted); }
.category-tile.is-empty .category-icon-box { opacity: 0.5; }

.category-icon-box {
  position: relative;
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  box-shadow: 0 0 0 2px transparent;
  transition: box-shadow 0.15s;
}

.category-icon-box.is-active {
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--focus-ring);
}

.category-tile-label {
  font-size: 11px;
  font-weight: 500;
  text-align: center;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 64px;
}

/* ---------- Selected categories row ---------- */

.selected-cats {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 4px 0 8px;
}

.selected-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px 3px 3px;
  border: 1px solid var(--brand-text);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}

.selected-chip-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.selected-chip-icon svg { width: 13px; height: 13px; }

.refine-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}

.match-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.match-btn {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}

.match-btn.active {
  background: var(--brand);
  color: var(--on-brand);
  border-color: var(--brand);
}

.match-hint {
  margin: 0 0 8px;
  font-size: 12px;
  color: var(--text-muted);
}

/* ---------- Subcategory drill-down (refine) ---------- */

/* A panel tinted with the selected category's colour, so it reads as a distinct step under the chips. */
.refine-group {
  margin: 0 0 10px;
  padding: 8px 8px 4px;
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--refine-color) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--refine-color) 35%, var(--border));
}

.refine-group.is-new { animation: refine-in 0.22s ease-out; }

@keyframes refine-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .refine-group.is-new { animation: none; }
}

.refine-label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.refine-label strong { color: var(--text); font-weight: 600; }

.refine-dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--refine-color);
}

/* chips wrap onto extra lines instead of sliding sideways */
.refine-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 2px 0 6px;
}

.refine-row-nested {
  margin-left: 10px;
  padding-left: 10px;
  border-left: 2px solid color-mix(in srgb, var(--refine-color) 45%, var(--border));
}

.refine-parent {
  flex: none;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.refine-chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 3px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.refine-chip:hover { border-color: var(--refine-color); }

/* the round picture: an icon on the category colour, or a photo when categories.json gives an image */
.refine-chip-visual {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--refine-color);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.refine-chip-visual svg { width: 14px; height: 14px; }
.refine-chip-visual img { width: 100%; height: 100%; object-fit: cover; }

.refine-chip.active {
  background: var(--brand);
  color: var(--on-brand);
  border-color: var(--brand);
}

.refine-chip.is-empty:not(.active) .refine-chip-label { color: var(--text-muted); }
.refine-chip.is-empty:not(.active) .refine-chip-visual { opacity: 0.5; }

.refine-count {
  font-size: 11px;
  font-weight: 600;
}

.refine-chip:not(.active) .refine-count, .flyout-item .refine-count { color: var(--text-muted); }

/* ---------- Hover flyout (mouse devices) ---------- */

.category-rail-wrap { position: relative; }

.category-flyout {
  position: absolute;
  z-index: 14;
  width: 272px;
  display: flex;
  flex-direction: column;
  max-height: min(70vh, 460px);
  padding: 6px;
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--refine-color) 45%, var(--border));
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
  animation: flyout-in 0.12s ease-out;
}

/* a submenu opened from a row of the list beside it */
.category-flyout.flyout-sub { width: 236px; z-index: 15; }

@keyframes flyout-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .category-flyout { animation: none; }
}

/* no visible scrollbar: the wheel still works, and the ▲ ▼ strips scroll while the mouse rests on them */
.flyout-scroll {
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: none;
}

.flyout-scroll::-webkit-scrollbar { display: none; }

.flyout-edge {
  position: absolute;
  left: 6px;
  right: 6px;
  z-index: 1;
  height: 20px;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  color: var(--text-muted);
  cursor: default;
}

.flyout-edge.is-on { display: flex; }
.flyout-edge-top { top: 6px; background: linear-gradient(to bottom, var(--surface) 55%, transparent); }
.flyout-edge-bottom { bottom: 6px; background: linear-gradient(to top, var(--surface) 55%, transparent); }

.flyout-title {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 2px 6px 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.flyout-list { list-style: none; margin: 0; padding: 0; }

.flyout-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 5px 8px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.flyout-item:hover, .flyout-item:focus-visible { background: var(--surface-2); }
.flyout-item.is-empty .flyout-name { color: var(--text-muted); }
.flyout-item.is-empty .refine-chip-visual { opacity: 0.5; }
.flyout-all { font-weight: 600; }

.flyout-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.flyout-more { flex: none; color: var(--text-muted); font-size: 15px; line-height: 1; }

.flyout-item .refine-chip-visual { width: 22px; height: 22px; }
.flyout-item .refine-chip-visual svg { width: 12px; height: 12px; }

.screen-head { margin: 10px 0 12px; }
.screen-head .card-desc { margin: 2px 0 0; }

