/*
  catalog.css — public catalog layout only. Tokens, reset, buttons and form
  controls all come from base.css (loaded first). Mobile-first: base rules
  target 320px, min-width queries only widen from there.
*/

/* ---------------------------------------------------------------------
   Header
   --------------------------------------------------------------------- */

.site-header {
  padding-block: var(--space-4);
  border-bottom: 1px solid var(--c-border);
}

.site-header h1 {
  font-size: var(--fs-4);
  font-weight: 600;
}

/* ---------------------------------------------------------------------
   Announcement — a bordered callout on surface, not a colored banner.
   Omitted entirely from the markup when empty.
   --------------------------------------------------------------------- */

.announcement {
  padding-block: var(--space-4) 0;
}

.announcement-box {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  font-size: var(--fs-2);
}

.announcement-box p:last-child {
  margin-bottom: 0;
}

/* ---------------------------------------------------------------------
   Filter chips — horizontally scrollable, scroll-snapping, sticky below
   the header, scrollbar hidden but still scrollable and keyboard reachable.
   --------------------------------------------------------------------- */

.chips-wrap {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--c-bg);
  border-bottom: 1px solid var(--c-border);
}

.chips {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  padding-block: var(--space-3);

  /* Scrollbar hidden, scrolling (mouse, touch, and keyboard via Tab) still
     works -- hiding the scrollbar never removes focusability. */
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.chips::-webkit-scrollbar {
  display: none;
}

.chip {
  flex-shrink: 0;
  scroll-snap-align: start;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding-inline: var(--space-4);
  border-radius: var(--radius-pill);
  border: 1px solid var(--c-border);
  background: var(--c-bg);
  color: var(--c-text);
  font-size: var(--fs-2);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.chip.chip-active {
  background: var(--c-accent);
  border-color: var(--c-accent);
  color: #ffffff;
}

/* ---------------------------------------------------------------------
   Product grid — 2 columns at 320px, 3 at 480px, 4 at 768px, 5 at 1024px.
   --------------------------------------------------------------------- */

.category-section {
  padding-block: var(--space-6) 0;
}

.category-section h2 {
  margin-bottom: var(--space-3);
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-4);
}

@media (min-width: 480px) {
  .product-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 768px) {
  .product-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (min-width: 1024px) {
  .product-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}

/* ---------------------------------------------------------------------
   Product card — bordered box, no shadow, the whole card is one tap target.
   --------------------------------------------------------------------- */

.product-item {
  min-width: 0;
}

.product-card {
  display: block;
  padding: 0;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
}

.thumb,
.thumb-placeholder {
  display: block;
  width: 100%;
  /* height:auto is load-bearing, not tidiness: the <img> carries width/height
     attributes, which the UA applies as a presentational height. That would
     make both dimensions definite and cause aspect-ratio to be ignored, so the
     thumbnail would render at its full 400px inside a ~163px grid column. */
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
}

.thumb-placeholder,
.detail-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
}

.thumb-placeholder span,
.detail-placeholder span {
  font-size: var(--fs-5);
  font-weight: 700;
  color: var(--c-muted);
}

.card-body {
  padding: var(--space-3);
}

.product-title {
  font-size: var(--fs-3);
  font-weight: 600;
  margin-bottom: var(--space-1);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-desc {
  font-size: var(--fs-2);
  line-height: 1.4;
  margin-bottom: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------------------------------------------------------------------
   Popup — a native <dialog>. Bottom sheet on mobile, centered card on
   desktop. Header (title + 44px close X) stays sticky inside the dialog.
   --------------------------------------------------------------------- */

.product-dialog {
  padding: 0;
  border: 0;
  background: var(--c-bg);
  color: var(--c-text);
  box-shadow: var(--shadow-dialog);
  max-width: 100%;
  width: 100%;
  max-height: 92vh;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  position: fixed;
  inset: auto 0 0 0;
  margin: 0;
  overscroll-behavior: contain;
}

.product-dialog::backdrop {
  background: rgba(0, 0, 0, 0.5);
}

/* display is set only for the [open] state -- the UA stylesheet's
   dialog:not([open]) { display: none } must keep winning while closed. */
.product-dialog[open] {
  display: flex;
  flex-direction: column;
}

@media (min-width: 768px) {
  .product-dialog {
    width: calc(100% - (2 * var(--space-6)));
    max-width: 560px;
    max-height: 85vh;
    border-radius: var(--radius-lg);
    inset: 0;
    margin: auto;
  }
}

.dialog-header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  /* flex-start, not center: a long title wraps to several lines (up to the
     120-char max), and centering would let the close X drift down into the
     middle of the block instead of staying pinned to the first line where a
     close control is expected. */
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  background: var(--c-bg);
  border-bottom: 1px solid var(--c-border);
  flex-shrink: 0;
}

.dialog-header h2 {
  font-size: var(--fs-4);
  overflow-wrap: anywhere;
}

.dialog-close {
  flex-shrink: 0;
  min-width: 44px;
  min-height: 44px;
  border-radius: var(--radius-md);
  font-size: 24px;
  line-height: 1;
  color: var(--c-text);
}

.dialog-close:hover {
  background: var(--c-surface);
}

.dialog-body {
  overflow-y: auto;
  padding: var(--space-4);
}

.dialog-image {
  width: 100%;
  /* Deliberately NOT cropped to a square like the grid thumbnail: this is the
     view the visitor opened to actually look at the product, so the whole
     image has to be visible. contain + a surface background letterboxes tall
     or wide photos instead of cutting them off. */
  height: auto;
  max-height: 60vh;
  object-fit: contain;
  background: var(--c-surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--c-border);
  margin-bottom: var(--space-4);
}

.detail-placeholder {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-md);
  border: 1px solid var(--c-border);
  margin-bottom: var(--space-4);
}

.dialog-desc {
  margin-bottom: var(--space-3);
}

/* ---------------------------------------------------------------------
   Pricing table — scrolls inside its own container; value column right
   aligns and wraps; the table never forces page scroll.
   --------------------------------------------------------------------- */

.pricing-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.pricing-table {
  border-collapse: collapse;
  width: 100%;
  font-size: var(--fs-2);
}

.pricing-table td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--c-border);
  vertical-align: top;
}

.pricing-table td.pl {
  font-weight: 600;
}

.pricing-table td.pv {
  text-align: right;
  word-break: break-word;
}

.pricing-scroll p {
  margin-bottom: var(--space-2);
}

/* ---------------------------------------------------------------------
   No-JS fallback panel — full detail rendered server-side above the grid.
   --------------------------------------------------------------------- */

.product-panel {
  margin-block: var(--space-5) var(--space-6);
}

.back-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-bottom: var(--space-3);
  font-weight: 600;
}

.panel-image {
  width: 100%;
  max-width: 320px;
  height: auto;
  max-height: 60vh;
  object-fit: contain;
  background: var(--c-surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--c-border);
  margin-bottom: var(--space-4);
}

.product-panel h2 {
  margin-bottom: var(--space-2);
}

.panel-desc {
  margin-bottom: var(--space-3);
}

/* ---------------------------------------------------------------------
   Empty state — a short line of text, nothing else.
   --------------------------------------------------------------------- */

.empty-state {
  padding-block: var(--space-7);
  text-align: center;
}

main.container {
  padding-bottom: var(--space-7);
}
