/* Product catalogues — the library grid and the reader.
   Loaded only on /tools/catalogs/ via extraCss, the same way the Device
   Finder loads its own stylesheet. Tokens are the site's; nothing here
   defines a colour of its own. */

/* ---- The library ---------------------------------------------------- */
.cat-grid { display: grid; gap: 18px; grid-template-columns: 1fr; }
@media (min-width: 620px) { .cat-grid { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); } }

.cat-card {
  border: 1px solid var(--sg-line); border-radius: var(--sg-r-sm);
  background: var(--sg-paper); overflow: hidden;
  display: flex; flex-direction: column;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.cat-card:hover { border-color: var(--sg-blue); box-shadow: var(--sg-shadow); transform: translateY(-2px); }
.cat-card__link { display: block; border: 0; }
.cat-card__cover { display: block; background: var(--sg-shell); padding: 18px 18px 0; }
.cat-card__cover img {
  display: block; width: 100%; height: auto; border-radius: 4px;
  box-shadow: 0 4px 14px rgba(18, 42, 79, .18);
}
.cat-card__body { display: block; padding: 15px 17px 13px; }
.cat-card__name { display: block; color: var(--sg-navy); }
.cat-card__meta { display: block; font-size: 14px; color: var(--sg-muted); margin-top: 2px; }
.cat-card__cta { display: block; font-size: 14px; font-weight: 800; color: var(--sg-blue-600); margin-top: 9px; }
.cat-card__pdf {
  display: flex; align-items: center; gap: 7px; margin-top: auto;
  padding: 11px 17px; border: 0; border-top: 1px solid var(--sg-line);
  font-size: 14px; font-weight: 700; color: var(--sg-muted); background: transparent;
}
.cat-card__pdf:hover { color: var(--sg-navy); background: var(--sg-tint); }
.cat-noscript { margin-top: 16px; font-size: 14px; color: var(--sg-muted); }

/* ---- The reader ------------------------------------------------------ */
/* Fixed rather than inline: a catalogue page is a tall A4, and on a phone
   the only way to show one at a readable size is to use the whole screen. */
.cat-reader {
  position: fixed; inset: 0; z-index: 60;
  display: flex; flex-direction: column;
  background: var(--sg-midnight);
}
.cat-reader[hidden] { display: none; }

.cat-reader__bar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; background: rgba(0, 0, 0, .22);
  border-bottom: 1px solid rgba(255, 255, 255, .1);
}
.cat-reader__title {
  flex: 1; margin: 0; min-width: 0; text-align: center;
  font-size: 14px; font-weight: 800; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cat-reader__tools { display: flex; gap: 6px; }

.cat-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 12px; border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 8px; background: rgba(255, 255, 255, .07);
  font: 800 13px/1 var(--sg-font); color: #fff; cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.cat-btn:hover { background: rgba(255, 255, 255, .16); border-color: rgba(255, 255, 255, .3); }
.cat-btn:focus-visible { outline: 2px solid var(--sg-sky); outline-offset: 2px; }
.cat-btn--icon { padding: 8px; }
.cat-btn span { display: none; }
@media (min-width: 620px) { .cat-btn span { display: inline; } }

.cat-stage {
  flex: 1; position: relative; display: flex; align-items: center; justify-content: center;
  padding: 14px; min-height: 0; overflow: hidden;
}
/* The spread needs a definite height for the pages to size against, or they
   take their natural height and the bottom of the page is cut off by the
   stage. It looks like a rendering fault and is a CSS one. */
.cat-spread { height: 100%; }
/* Zoomed: the page is shown at its own pixel size and the stage scrolls,
   which is what a reader wants when the type is 8 pt on paper. */
.cat-stage.is-zoomed { overflow: auto; align-items: flex-start; justify-content: flex-start; cursor: zoom-out; }

.cat-spread { display: flex; gap: 2px; align-items: center; justify-content: center; }
.cat-stage.is-zoomed .cat-spread { height: auto; }

.cat-page {
  display: block; width: auto; height: auto; max-height: 100%; max-width: 100%;
  background: #fff; box-shadow: 0 10px 40px rgba(0, 0, 0, .45);
  /* Reserved before the image arrives, so the spread does not jump when a
     page finishes loading. */
  aspect-ratio: 595 / 842;
}
/* Two pages share the width; each still fits the height first, so a spread
   is letterboxed rather than cropped. */
.cat-spread.is-spread .cat-page { max-width: calc(50% - 1px); }
.cat-stage.is-zoomed .cat-page { max-height: none; max-width: none; }
.cat-page.is-blank { visibility: hidden; }

/* The turn. A slide, not a simulated sheet of paper: the flip library that
   did the latter cost 43 kB and a rewrite of the reader around it. */
.cat-spread.is-turning { transition: transform .18s ease, opacity .18s ease; }
.cat-spread.turn-next { transform: translateX(-2.5%); opacity: .35; }
.cat-spread.turn-prev { transform: translateX(2.5%); opacity: .35; }
@media (prefers-reduced-motion: reduce) {
  .cat-spread.is-turning { transition: none; }
  .cat-spread.turn-next, .cat-spread.turn-prev { transform: none; opacity: 1; }
}

.cat-nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
  display: flex; align-items: center; justify-content: center;
  width: 44px; height: 64px; padding: 0;
  border: 1px solid rgba(255, 255, 255, .16); border-radius: 10px;
  background: rgba(0, 0, 0, .4); color: #fff; cursor: pointer;
  transition: background .15s ease, opacity .15s ease;
}
.cat-nav:hover { background: rgba(0, 0, 0, .62); }
.cat-nav:focus-visible { outline: 2px solid var(--sg-sky); outline-offset: 2px; }
.cat-nav[disabled] { opacity: .25; cursor: default; }
.cat-nav--prev { left: 8px; }
.cat-nav--next { right: 8px; }
.cat-stage.is-zoomed .cat-nav { display: none; }

.cat-reader__foot {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: rgba(0, 0, 0, .22); border-top: 1px solid rgba(255, 255, 255, .1);
}
.cat-count { font-size: 13px; font-weight: 700; color: rgba(255, 255, 255, .82); white-space: nowrap; }
.cat-slider { flex: 1; accent-color: var(--sg-sky); }
.cat-slider:focus-visible { outline: 2px solid var(--sg-sky); outline-offset: 3px; }

/* The site's header is fixed; the reader covers it, so the page behind must
   not scroll while it is open. */
body.cat-open { overflow: hidden; }
