/* css/browse.css — browse UI: category stack, TABS view, availability states.
 *
 * OWNER: W2. Created by W0 (00-contracts.md §5 [A3]).
 *
 * style.css is FROZEN — every new browse/tab rule goes here. This sheet is
 * linked AFTER style.css in index.html, so a rule here wins by cascade order
 * without needing !important. Scoped to #screen-categories/#screen-category-list
 * (this module's own screens) wherever a selector could otherwise leak onto a
 * sibling workstream's screen.
 */

/* A tab bar this module leaves unpopulated (a leaf entered directly, no TABS
 * parent) takes no room at all. */
#cat-tab-bar:empty,
#cat-subtab-bar:empty {
  display: none;
}

/* ===== TOP-NAV LAYOUT FIX (the root grid screen) =====
 * .top-nav-title's `flex: 1` (style.css) targets the title itself, but there
 * it sits inside an unclassed wrapper <div> (title + subtitle) alongside the
 * mode-switch button — the wrapper is what needs to grow so the button is
 * pushed to the right edge instead of hugging the title. */
#screen-categories .top-nav > div:first-child {
  flex: 1;
  min-width: 0;
}

/* ===== LABELLED BACK CONTROL (plan 17 WP-4, D2 option B) =====
 * "‹ Italok" / "‹ Összes kategória": the ONE tappable thing in the title row
 * besides the two right-side buttons, so it gets the same grey pill treatment
 * as them and the bottom-bar ‹ — a control, not a caption. The title next to
 * it is plain text and reads as one. */
.nav-back {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 360px;
  background: var(--light-gray);
  border: none;
  border-radius: var(--radius-pill);
  padding: 14px 24px 14px 20px;
  font-size: 22px;
  font-weight: 700;
  color: var(--dark);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.15s, transform 0.1s;
}
.nav-back:active { background: var(--hairline); transform: scale(0.96); }
#cat-list-back-label {
  overflow: hidden;
  text-overflow: ellipsis;
}
#screen-category-list .top-nav-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== MODE SWITCH (§6.3 A19) =====
 * Reveals as a compact pill once init() wires it; label reflects the CURRENT
 * mode, tapping opens the (W0-built) confirm dialog to switch to the other. */
.mode-switch-btn {
  flex-shrink: 0;
  background: var(--light-gray);
  border: none;
  border-radius: var(--radius-pill);
  padding: 14px 22px;
  font-size: 16px;
  font-weight: 700;
  color: var(--dark);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, transform 0.1s;
}
.mode-switch-btn:active { background: var(--hairline); transform: scale(0.96); }

/* ===== TOP-LEVEL CATEGORY STRIP (#cat-subtab-bar) =====
 * Every top-level category as .cat-tab pills (style.css) — the same list the
 * grid screen shows, so switching from Leves to Tészta is one direct tap
 * (the 2026-08-02 finding). Since plan 17 WP-4 it sits directly under the
 * title row and is the ONLY pill row. See renderTopLevelStrip() /
 * topLevelAncestorId() in lib/ui/browse.mjs. */
.cat-subtab-bar {
  padding-top: 10px;
  padding-bottom: 10px;
  background: var(--cream);
  border-bottom: 1px solid var(--hairline);
}
.cat-subtab-bar .cat-tab {
  padding: 12px 20px;
  font-size: 16px;
}

/* ===== TABS: a segmented control glued to the content (plan 17 D3 ii) =====
 * A TABS node's children in #cat-tab-bar. Deliberately NOT pills: two rows of
 * identical pills whose meaning differs (siblings vs. top-level) was Tamás's
 * T3. Each tab fills an equal share, the active one is underlined in red and
 * bold — the one shape a guest already reads as "tabs of the thing I am in",
 * and it cannot be confused with the strip above it. The bar's own hairline
 * makes the tabs read as attached to the list below. Overrides style.css's
 * .cat-tab pill by cascade order. */
#cat-tab-bar {
  padding: 0 24px;
  gap: 0;
  background: var(--white);
  border-bottom: 1px solid var(--hairline);
}
#cat-tab-bar .cat-tab {
  flex: 1 1 0;
  min-width: 0;
  background: transparent;
  border-radius: 0;
  border-bottom: 4px solid transparent;
  padding: 20px 12px 16px;
  font-size: 19px;
  font-weight: 600;
  color: var(--mid-gray);
  text-align: center;
  white-space: normal;
  line-height: 1.2;
}
#cat-tab-bar .cat-tab:active { transform: none; background: var(--light-gray); }
#cat-tab-bar .cat-tab.active {
  background: transparent;
  color: var(--red);
  font-weight: 800;
  border-bottom-color: var(--red);
  box-shadow: none;
}

/* ===== AVAILABILITY: not_orderable / sold_out (§2) =====
 * Same greying for both states — the badge text is what tells them apart
 * (§6.2 A10). No shadow, ~40% opacity, no tap handler (the row simply has no
 * onclick attribute at all — see browse.mjs rowAttrs()). */
.menu-item-row.unavailable,
.menu-list-row.unavailable {
  opacity: 0.4;
  box-shadow: none;
  cursor: default;
}
.menu-item-row.unavailable:active,
.menu-list-row.unavailable:active {
  transform: none;
}
.availability-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  background: rgba(29,29,27,0.82);
  color: var(--white);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  padding: 6px 8px;
  border-radius: 10px;
  line-height: 1.2;
}
.availability-badge-inline {
  position: static;
  display: inline-block;
  background: rgba(29,29,27,0.82);
  color: var(--white);
  font-size: 13px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  margin-left: 12px;
}

/* ===== DEPOSIT HINT ===== */
.deposit-hint {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--blue-dark);
  margin-top: 4px;
}
.menu-item-row.selected .deposit-hint { color: rgba(255,255,255,0.9); }

/* ===== BAR-PICKUP MARK (notice_nonfiscal, §6.2 A9) ===== */
.bar-pickup-mark {
  color: var(--red);
  font-weight: 800;
  margin-left: 4px;
}
.menu-item-row.selected .bar-pickup-mark { color: var(--white); }

/* ===== LIST VIEW =====
 * Names only, one per row, no image, price on the right when > 0
 * (visual-spec-summary). Used for a leaf category whose own view is LIST,
 * and reused by W3 for option-value LIST steps. */
.menu-list-row {
  display: flex;
  align-items: center;
  min-height: 84px;
  padding: 0 28px;
  gap: 14px;
  cursor: pointer;
  background: var(--white);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  font-size: 19px;
  font-weight: 600;
  transition: background 0.15s, transform 0.1s;
}
.menu-list-row:active { transform: scale(0.985); }
.menu-list-row-name {
  flex: 1;
}
.menu-list-row-price {
  font-size: 16px;
  font-weight: 700;
  color: var(--mid-gray);
  white-space: nowrap;
}

/* ===== GRID VIEW: product tiles (plan 17 WP-3, T5 / D4) =====
 * A GRID leaf renders as 3-across tiles instead of the CARD row — VENDEL's
 * GRID means "N×M image + name", and 27 drinks in one leaf (Tamás's Tea és
 * Üdítő) is the real case. The list node gets .menu-grid only for that render;
 * .menu-list's own column layout (style.css) applies otherwise. 1080 − 2×24
 * padding − 2×20 gap = 992 / 3 ≈ 330 px per tile (D4). */
.menu-list.menu-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  padding: 24px;
}
.product-tile {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 12px 16px;
  background: var(--white);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s;
}
.product-tile:active { transform: scale(0.96); }
.tile-photo {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 14px;
  overflow: hidden;
  background: var(--light-gray);
  display: flex;
  align-items: center;
  justify-content: center;
}
.tile-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.tile-photo-placeholder { font-size: 64px; }
/* The price sits on the image's corner, as on the card; the availability
 * badge (.availability-badge, absolute top) lands over the image too. */
.tile-photo .price-badge { font-size: 17px; padding: 6px 14px; }
.tile-name {
  font-size: 18px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  line-height: 1.25;
  min-height: 2.5em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.product-tile .deposit-hint { margin-top: -4px; }
/* Same greying rule as the rows: no shadow, 40 %, no tap (rowAttrs()). */
.product-tile.unavailable {
  opacity: 0.4;
  box-shadow: none;
  cursor: default;
}
.product-tile.unavailable:active { transform: none; }
/* A GRID category node reuses the root grid's .category-card tile; the
 * .menu-grid columns apply to it the same way. */
.menu-grid .category-card { margin: 0; }

/* ===== LOADING PLACEHOLDER (state.menuModel not ready yet) ===== */
.menu-loading {
  padding: 80px;
  text-align: center;
  color: var(--mid-gray);
  font-size: 22px;
  grid-column: 1 / -1;
}

/* ===== PRODUCT-LIST CART CTA: count vs total (F2) =====
 * Same defect as the cart bottom bar ("🍽 5 &nbsp; 22 950 Ft" reading as one
 * number), same remedy — but this badge sits on the red CTA, so it is
 * light-on-red rather than the cart bar's red-on-white. */
#cat-list-cart-btn {
  display: flex;
  align-items: center;
  gap: 12px;
}
.cta-count-badge {
  background: var(--white);
  color: var(--red);
  font-size: 18px;
  font-weight: 800;
  min-width: 34px;
  height: 34px;
  padding: 0 8px;
  border-radius: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cta-sep {
  width: 2px;
  height: 26px;
  background: rgba(255, 255, 255, 0.45);
  border-radius: 1px;
}
.cta-amount { font-weight: 800; }
.cta-go { font-weight: 700; }
