/* The catalog's pages (docs/STAGE54_PLAN.md §5.5): the approved sketch's look on style.css's tokens — phone first, the
   desktop layout with the QR from 900 px. Hand-written; the pages themselves are built by scripts/catalog-pages.ts. */

body[data-page="catalog"] { font-size: 15px; line-height: 1.45; }
body[data-page="catalog"] h1 { font-size: 28px; line-height: 1.1; letter-spacing: -0.03em; }
body[data-page="catalog"] h2 { font-size: 21px; line-height: 1.2; letter-spacing: -0.02em; }
.cat a { text-decoration: none; }

/* The top bar */
.cat-top { position: sticky; top: 0; z-index: 10; background: var(--teal); color: var(--on-teal); }
.cat-wrap { width: min(1100px, 100%); margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 12px; }
.cat-brand, .cat-brand-picker { display: flex; align-items: center; gap: 10px; flex-grow: 1; color: inherit; text-decoration: none; line-height: 1.2; }
.cat-brand img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
.cat-brand span, .cat-brand-picker { display: flex; flex-direction: column; }
.cat-brand b, .cat-brand-picker b { font-size: 16px; font-weight: 800; }
.cat-brand small, .cat-brand-picker small { font-size: 12px; color: var(--on-teal-muted); }
.cat-nav { display: none; }
.cat-top-btn { color: var(--on-teal); font-weight: 700; font-size: 13px; padding: 12px 4px; text-decoration: none; white-space: nowrap; }

/* The page */
.cat { width: min(1100px, 100%); margin: 0 auto; padding: 14px 16px 32px; display: flex; flex-direction: column; gap: 28px; }
.cat p { color: var(--muted); }
.cat-hero, .cat-head, .cat-intro, .cat-block, .cat-gallery { display: flex; flex-direction: column; gap: 12px; }
.cat-hero h1 { font-size: 31px; line-height: 1.08; }
.cat-back { align-self: flex-start; font-size: 13px; font-weight: 700; color: var(--teal); padding: 6px 0; }
.cat-small { font-size: 13px; color: var(--muted); }

/* Buttons */
.cat-btn { display: block; background: var(--mustard); color: var(--on-mustard); font-weight: 800; font-size: 16px; padding: 16px 18px; border-radius: 14px; text-align: center; }
.cat-btn-line { background: transparent; border: 2px solid var(--teal); color: var(--teal); }
.cat-more { font-size: 13px; font-weight: 700; color: var(--teal); text-align: center; padding: 12px; }
.cat-end { display: flex; flex-direction: column; gap: 8px; }

/* «Для кого» */
.cat-for { display: flex; flex-direction: column; gap: 8px; margin-top: -12px; }
.cat-for > span { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.cat-chips, .cat-facts, .cat-links { display: flex; flex-wrap: wrap; gap: 8px; }
.cat-chip, .cat-facts span, .cat-links a { background: var(--surface); border: 1px solid var(--line); font-weight: 700; font-size: 13px; padding: 8px 13px; border-radius: 999px; color: var(--ink); }
.cat-chip[aria-current="true"] { background: var(--teal); border-color: var(--teal); color: var(--on-teal); }
.cat-facts span { font-size: 12px; padding: 7px 11px; }

/* Shelves and cards */
.cat-shelf { display: flex; flex-direction: column; gap: 12px; }
.cat-shelf-head { display: flex; align-items: baseline; justify-content: space-between; }
.cat-shelf-head a { font-size: 13px; font-weight: 700; color: var(--teal); padding: 8px 0 8px 12px; }
.cat-row { display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding-inline: 16px; margin: 0 -16px; padding: 0 16px 4px; }
.cat-row .cat-card { flex: 0 0 168px; scroll-snap-align: start; }
.cat-card { display: flex; flex-direction: column; gap: 8px; color: var(--ink); }
.cat-card-img { display: block; aspect-ratio: 1; border-radius: 14px; overflow: hidden; background: var(--sunk); }
.cat-card-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cat-card-hook { font-size: 14px; line-height: 1.25; font-weight: 700; }
.cat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 12px; }
.cat-card[hidden], .cat-shelf[hidden] { display: none; }

/* A scenario */
.cat-scenario { display: flex; flex-direction: column; gap: 12px; }
/* The header's picture or loop whole, in its own shape (catalog-pages.ts headerMedia): its width and height give the box
   before it loads; a tall one (a chat) keeps a phone's width, so it never towers over the page. */
.cat-media { width: 100%; margin-inline: auto; }
.cat-media img, .cat-media video { width: 100%; height: auto; display: block; border-radius: 16px; background: #121d1c; }
.cat-media-tall { max-width: 430px; }
.cat-intro { gap: 12px; }
.cat-qr { display: none; }
.cat-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; counter-reset: step; }
.cat-steps li { display: flex; gap: 12px; align-items: flex-start; counter-increment: step; }
.cat-steps li::before { content: counter(step); flex: 0 0 30px; height: 30px; border-radius: 50%; background: var(--teal); color: var(--on-teal); font-weight: 800; font-size: 14px; display: flex; align-items: center; justify-content: center; }

/* A gallery */
.cat-band { background: var(--teal); color: var(--on-teal); border-radius: 14px; padding: 12px 14px; display: flex; flex-direction: column; gap: 3px; }
.cat-band b { font-size: 14px; }
.cat-band span { font-size: 13px; color: var(--on-teal-muted); }
.cat-done { background: var(--surface); border: 2px solid var(--mustard); border-radius: 12px; padding: 10px 12px; font-size: 13px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.cat-done[hidden] { display: none; }
.cat-done span { flex-grow: 1; }
.cat-done-link { color: var(--teal); padding: 8px 0; }
.cat-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 12px; }
.cat-tile { display: flex; flex-direction: column; gap: 6px; }
.cat-tile-img { display: block; aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden; background: #121d1c; }
.cat-tile-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cat-tile > b { font-size: 14px; line-height: 1.2; font-weight: 800; }
.cat-tile > span { font-size: 12px; line-height: 1.3; color: var(--muted); min-height: 31px; }
.cat-tile-do { display: flex; align-items: center; gap: 6px; }
.cat-code { display: inline-flex; align-items: center; gap: 5px; background: var(--sunk); border: 0; border-radius: 8px; padding: 8px 9px; font: 700 12px ui-monospace, Menlo, Consolas, monospace; color: var(--ink); min-height: 44px; cursor: pointer; }
.cat-code svg { color: var(--muted); }
.cat-in-style { flex-grow: 1; text-align: center; background: var(--mustard); color: var(--on-mustard); font-weight: 800; font-size: 13px; padding: 13px 6px; border-radius: 8px; box-shadow: 0 2px 0 rgba(0, 0, 0, .12); }
.cat-in-style:hover { filter: brightness(1.06); }
.cat-tile[aria-current="true"] .cat-tile-img { outline: 3px solid var(--mustard); outline-offset: 2px; }
.cat-tile[aria-current="true"] .cat-in-style { background: var(--teal); color: var(--on-teal); }

/* Boxes */
.cat-note, .cat-faq, .cat-ask { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 6px; }
.cat-note b, .cat-faq b, .cat-ask b { font-size: 14px; font-weight: 800; }
.cat-note span, .cat-faq span, .cat-ask span { font-size: 13px; color: var(--muted); }
.cat-ask .cat-btn { margin-top: 6px; }
.cat-faq + .cat-faq { margin-top: -2px; }
.cat-near { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; display: flex; flex-direction: column; }
.cat-near a { display: flex; align-items: center; gap: 12px; padding: 12px 14px; color: var(--ink); }
.cat-near a + a { border-top: 1px solid var(--sunk); }
.cat-near img { width: 52px; height: 52px; border-radius: 10px; object-fit: cover; }
.cat-near span { font-weight: 700; font-size: 14px; line-height: 1.25; }

/* A style */
.cat-name { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cat-parts { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; display: flex; flex-direction: column; }
.cat-part { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; }
.cat-part + .cat-part { border-top: 1px solid var(--sunk); }
.cat-part small { font-size: 12px; font-weight: 700; color: var(--muted); }
.cat-link-btn { background: var(--surface); border: 1px solid var(--teal); color: var(--teal); font-weight: 800; font-size: 13px; padding: 10px 14px; border-radius: 999px; }
.cat-similar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.cat-similar a { display: flex; flex-direction: column; gap: 4px; color: var(--ink); }
.cat-similar img { aspect-ratio: 16 / 9; width: 100%; border-radius: 12px; object-fit: cover; }
.cat-similar b { font-size: 14px; }
.cat-similar span { font: 700 12px ui-monospace, Menlo, Consolas, monospace; color: var(--muted); }

/* The picker (?from=chat): the chat's choice, nothing else */
.cat-picker-only { display: none; }
body.picker .cat-picker-only { display: flex; }
body.picker .cat-hide-picker, body.picker .cat-brand, body.picker .cat-nav { display: none; }
body.picker .cat { padding-bottom: 140px; }
.cat-pickbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -12px 30px -18px rgb(0 0 0 / 40%); padding: 12px 16px; flex-direction: column; gap: 10px; }
.cat-pickbar[hidden] { display: none; }
.cat-pickbar > div { display: flex; flex-direction: column; gap: 2px; }
.cat-pickbar small { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.cat-pickbar b { font-size: 14px; }
.cat-pickbar span { font-size: 12px; color: var(--muted); }

/* Desktop: the shelves in the bar, the scenario beside its preview, the QR for a phone */
@media (min-width: 900px) {
  .cat-nav { display: flex; gap: 18px; flex-wrap: wrap; }
  .cat-nav a { color: var(--on-teal); font-size: 14px; font-weight: 700; text-decoration: none; }
  .cat-brand { flex-grow: 0; }
  .cat-wrap { gap: 28px; }
  .cat-wrap .cat-nav { flex-grow: 1; }
  .cat-top-btn { background: var(--mustard); color: var(--on-mustard); padding: 10px 16px; border-radius: 999px; }
  .cat { padding: 28px 24px 48px; gap: 40px; }
  body[data-page="catalog"] h1 { font-size: 40px; }
  .cat-hero h1 { font-size: 44px; }
  .cat-scenario { display: grid; grid-template-columns: 1.1fr 1fr; gap: 40px; align-items: start; }
  .cat-scenario .cat-media { order: 0; }
  .cat-intro > .cat-main-btn { display: none; }
  .cat-qr { display: grid; grid-template-columns: 1fr auto; gap: 18px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 16px; }
  .cat-qr > div:first-child { display: flex; flex-direction: column; gap: 8px; }
  .cat-qr small { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
  .cat-qr-img { display: flex; flex-direction: column; align-items: center; gap: 6px; }
  .cat-qr-code { width: 132px; height: 132px; display: block; }
  .cat-row { margin: 0; padding: 0 0 4px; scroll-padding-inline: 0; }
  .cat-row .cat-card { flex-basis: 200px; }
  .cat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .cat-tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .cat-similar { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .cat-end { flex-direction: row; align-items: center; justify-content: center; gap: 18px; }
  .cat-end .cat-btn { min-width: 320px; }
  .cat-head .cat-media { max-width: 520px; margin-inline: 0; }
  .cat-head .cat-main-btn { align-self: flex-start; min-width: 320px; }
  .cat-ask { max-width: 720px; }
  .cat-pickbar { flex-direction: row; align-items: center; justify-content: space-between; padding: 14px max(24px, calc((100% - 1052px) / 2)); }
}

@media (prefers-reduced-motion: reduce) {
  .cat-row { scroll-snap-type: none; }
}
