/* ══════════════════════════════════════════════════════════════════
   BS CATALOG — v1.0 · portable catalog shelf + flip-book modal
   ------------------------------------------------------------------
   Fully self-contained. No framework, no reset, no external font.
   Every visual value is a `--bsc-*` custom property, so a host site
   can re-skin the whole component by overriding the :root block —
   see THEMING at the bottom of this file.

   Scope: every selector is prefixed `.bsc-`. Nothing here touches a
   host page's own elements.
   ══════════════════════════════════════════════════════════════════ */

/* ──────────────────────────────────────────────────────────────────
   1. DESIGN TOKENS
   Override any of these on :root (or on the .bsc-shelf-section
   itself for a per-instance theme) to match a client's brand.
   ────────────────────────────────────────────────────────────────── */
:root {
  /* Colour — 60/30/10. Ink is the 60, surface the 30, accent the 10. */
  --bsc-ink:        #16161a;
  --bsc-ink-60:     rgba(22, 22, 26, 0.60);
  --bsc-ink-15:     rgba(22, 22, 26, 0.15);
  --bsc-ink-08:     rgba(22, 22, 26, 0.08);
  --bsc-accent:     #c8553d;
  --bsc-accent-rgb: 200, 85, 61;
  --bsc-surface:    #faf8f4;
  --bsc-cover-bg:   #1c1c20;

  /* Type — inherits the host's stack by default. */
  --bsc-sans: inherit;
  --bsc-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
              "Liberation Mono", monospace;

  /* Shape */
  --bsc-radius-md:   14px;
  --bsc-radius-pill: 999px;

  /* Motion */
  --bsc-ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --bsc-dur-fast: 0.3s;
  --bsc-dur-mid:  0.5s;
  --bsc-dur-slow: 0.7s;

  /* Layout */
  --bsc-cols:      4;      /* covers per row at full width */
  --bsc-gap:       clamp(20px, 2.4vw, 36px);
  --bsc-max-width: 1280px;
  --bsc-pad-x:     clamp(20px, 5vw, 64px);

  /* Modal */
  --bsc-modal-bg:  rgba(10, 10, 15, 0.92);
  --bsc-modal-z:   99000;
}

/* ──────────────────────────────────────────────────────────────────
   2. SECTION SHELL
   ────────────────────────────────────────────────────────────────── */
.bsc-shelf-section {
  padding: clamp(64px, 9vw, 128px) var(--bsc-pad-x);
  font-family: var(--bsc-sans);
  color: var(--bsc-ink);
  box-sizing: border-box;
}
.bsc-shelf-section *,
.bsc-shelf-section *::before,
.bsc-shelf-section *::after { box-sizing: border-box; }

.bsc-inner {
  max-width: var(--bsc-max-width);
  margin: 0 auto;
}

.bsc-head { margin-bottom: 8px; }

.bsc-head-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.bsc-eyebrow,
.bsc-counter {
  font-family: var(--bsc-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--bsc-ink-60);
}
.bsc-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--bsc-ink);
}
.bsc-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--bsc-accent);
  flex-shrink: 0;
}

.bsc-title {
  margin: 0;
  font-size: clamp(30px, 4.4vw, 58px);
  font-weight: 500;
  line-height: 1.06;
  letter-spacing: -0.028em;
  color: var(--bsc-ink);
}
.bsc-title em {
  font-style: italic;
  color: var(--bsc-accent);
}

/* ──────────────────────────────────────────────────────────────────
   3. THE SHELF
   ────────────────────────────────────────────────────────────────── */
.bsc-shelf {
  display: grid;
  grid-template-columns: repeat(var(--bsc-cols), minmax(0, 1fr));
  gap: var(--bsc-gap);
  margin: 48px 0 32px;
  list-style: none;
  padding: 0;
}
.bsc-shelf--1 {
  grid-template-columns: minmax(0, 1fr);
  width: min(100%, 820px);
}

.bsc-cover {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: 0;
  padding: 0;
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
  transition: transform var(--bsc-dur-mid) var(--bsc-ease-out);
}
.bsc-cover:focus { outline: none; }
.bsc-cover:focus-visible {
  outline: 2px solid var(--bsc-accent);
  outline-offset: 6px;
  border-radius: 4px;
}

/* ── Cover artwork ─────────────────────────────────────────────── */
.bsc-cover-img {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: var(--bsc-media-ratio, 1600 / 1132);
}
.bsc-cover-art {
  position: relative;
  display: block;
  max-width: 100%;
  max-height: 100%;
  border-radius: var(--bsc-radius-md);
  overflow: hidden;
  background: var(--bsc-cover-bg);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.04) inset,
    0 12px 32px -8px rgba(10, 10, 20, 0.22),
    0 4px 10px -2px rgba(10, 10, 20, 0.12);
  transition: box-shadow var(--bsc-dur-mid) var(--bsc-ease-out);
}
.bsc-cover-art.is-wide { width: 100%; height: auto; }
.bsc-cover-art.is-tall { width: auto; height: 100%; }
.bsc-cover-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
  user-select: none;
  transition: transform var(--bsc-dur-slow) var(--bsc-ease-out);
}
.bsc-cover-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(20px, 3vw, 34px);
  background:
    linear-gradient(135deg, rgba(var(--bsc-accent-rgb), .11), transparent 45%),
    #e8e3dc;
  border: 1px solid var(--bsc-ink-08);
}
.bsc-cover-placeholder::after {
  content: '';
  position: absolute;
  inset: 18% 10%;
  border-block: 1px solid var(--bsc-ink-08);
}
.bsc-cover-placeholder-brand {
  position: relative;
  z-index: 1;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: clamp(22px, 3vw, 38px);
  color: var(--bsc-ink);
}
.bsc-cover-placeholder-note {
  position: relative;
  z-index: 1;
  align-self: flex-end;
  font-family: var(--bsc-mono);
  font-size: 9px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--bsc-ink-60);
}

/* Right-edge spine accent — hint of a book on a shelf. */
.bsc-cover-art::after {
  content: "";
  position: absolute;
  inset: 0 0 0 auto;
  width: 3px;
  background: linear-gradient(to right, rgba(0, 0, 0, 0.18), transparent);
  pointer-events: none;
}

/* Floating "OPEN →" pill, revealed on hover / focus. */
.bsc-open-pill {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bsc-accent);
  color: #fff;
  padding: 8px 16px;
  border-radius: var(--bsc-radius-pill);
  font-family: var(--bsc-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 8px 20px -6px rgba(var(--bsc-accent-rgb), 0.5);
  transition: opacity var(--bsc-dur-fast) ease,
              transform 0.4s var(--bsc-ease-out);
}

.bsc-cover:hover .bsc-cover-art,
.bsc-cover:focus-visible .bsc-cover-art {
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.04) inset,
    0 24px 48px -8px rgba(10, 10, 20, 0.32),
    0 8px 20px -2px rgba(10, 10, 20, 0.18);
}
.bsc-cover:hover .bsc-cover-img img,
.bsc-cover:focus-visible .bsc-cover-img img { transform: scale(1.04); }

.bsc-cover:hover .bsc-open-pill,
.bsc-cover:focus-visible .bsc-open-pill {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Cover caption ─────────────────────────────────────────────── */
.bsc-cover-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 4px;
}
.bsc-cover-title {
  font-family: var(--bsc-sans);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.012em;
  line-height: 1.3;
  color: var(--bsc-ink);
}
.bsc-cover-edition {
  font-family: var(--bsc-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--bsc-ink-60);
}

/* ──────────────────────────────────────────────────────────────────
   4. COMING-SOON STATE
   Placeholder catalogs (no PDF yet). Disabled at the DOM level so
   clicks never fire; the class guard is belt-and-braces.
   ────────────────────────────────────────────────────────────────── */
.bsc-cover.is-soon { cursor: not-allowed; }
.bsc-cover.is-soon[disabled] {
  opacity: 0.78;
  filter: saturate(0.55);
  transition: opacity var(--bsc-dur-fast) ease,
              filter var(--bsc-dur-fast) ease;
}
.bsc-cover.is-soon[disabled]:hover,
.bsc-cover.is-soon[disabled]:hover .bsc-cover-img,
.bsc-cover.is-soon[disabled]:hover .bsc-cover-img img { transform: none; }
.bsc-cover.is-soon[disabled]:hover .bsc-cover-art {
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.04) inset,
    0 12px 32px -8px rgba(10, 10, 20, 0.22),
    0 4px 10px -2px rgba(10, 10, 20, 0.12);
}
.bsc-cover.is-soon .bsc-cover-title { color: var(--bsc-ink-60); }

.bsc-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px 5px 9px;
  border-radius: var(--bsc-radius-pill);
  background: rgba(10, 10, 20, 0.78);
  -webkit-backdrop-filter: blur(8px) saturate(140%);
          backdrop-filter: blur(8px) saturate(140%);
  color: #fff;
  font-family: var(--bsc-mono);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  pointer-events: none;
  box-shadow: 0 6px 18px -8px rgba(10, 10, 20, 0.4);
}
.bsc-badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--bsc-accent);
  box-shadow: 0 0 0 2px rgba(var(--bsc-accent-rgb), 0.18);
  flex-shrink: 0;
}
/* Pulse is opt-in: pointer-precise, non-lite, motion-allowed only. */
@media (hover: hover) and (pointer: fine) {
  html:not(.bsc-lite) .bsc-badge-dot {
    animation: bsc-soon-pulse 2.4s ease-in-out infinite;
  }
}
@keyframes bsc-soon-pulse {
  0%, 100% { opacity: 1;    transform: scale(1); }
  50%      { opacity: 0.55; transform: scale(0.85); }
}

/* ──────────────────────────────────────────────────────────────────
   5. SHELF FOOTNOTE
   ────────────────────────────────────────────────────────────────── */
.bsc-foot {
  margin: 32px 0 0;
  padding-top: 24px;
  border-top: 1px solid var(--bsc-ink-08);
  font-size: 13px;
  line-height: 1.6;
  color: var(--bsc-ink-60);
  text-align: center;
}
.bsc-foot kbd {
  display: inline-block;
  padding: 2px 7px;
  margin: 0 2px;
  font-family: var(--bsc-mono);
  font-size: 11px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid var(--bsc-ink-15);
  border-radius: 4px;
  color: var(--bsc-ink);
  box-shadow: 0 1px 0 rgba(10, 10, 15, 0.04);
}

/* ──────────────────────────────────────────────────────────────────
   6. MODAL — full-viewport overlay hosting the flip-book iframe
   ────────────────────────────────────────────────────────────────── */
.bsc-modal {
  position: fixed;
  inset: 0;
  z-index: var(--bsc-modal-z);
  background: var(--bsc-modal-bg);
  -webkit-backdrop-filter: blur(10px);
          backdrop-filter: blur(10px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.35s var(--bsc-ease-out), visibility 0s 0.35s;
}
.bsc-modal.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 0.35s var(--bsc-ease-out);
}

.bsc-modal-iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: #0a0a0f;
  opacity: 0;
  transition: opacity 0.4s ease 0.1s;
}
.bsc-modal.is-open .bsc-modal-iframe { opacity: 1; }

/* The viewer draws its own Close button. This one is a fallback,
   revealed only when the iframe fails to signal readiness (offline,
   blocked CDN) so the user is never trapped. */
.bsc-modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 1;
  display: none;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--bsc-radius-pill);
  color: rgba(240, 235, 226, 0.92);
  font-family: var(--bsc-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  cursor: pointer;
  -webkit-backdrop-filter: blur(12px);
          backdrop-filter: blur(12px);
  transition: background 0.2s ease, transform 0.2s ease;
}
.bsc-modal.is-open:not(.is-loaded) .bsc-modal-close { display: inline-flex; }
.bsc-modal-close:hover {
  background: rgba(var(--bsc-accent-rgb), 0.92);
  border-color: var(--bsc-accent);
  color: #fff;
  transform: translateY(-1px);
}
.bsc-modal-close svg { flex-shrink: 0; }

/* Scroll lock applied to <html> while the modal is open. */
html.bsc-modal-open { overflow: hidden; }

/* ──────────────────────────────────────────────────────────────────
   7. SCROLL REVEAL (JS-driven, opt-out safe)
   Elements only get hidden once JS confirms it can reveal them —
   `html.bsc-js` is set by catalog.js. No-JS users see everything.
   ────────────────────────────────────────────────────────────────── */
html.bsc-js:not(.bsc-lite) [data-bsc-reveal] {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.7s var(--bsc-ease-out),
              transform 0.7s var(--bsc-ease-out);
  transition-delay: var(--bsc-reveal-delay, 0ms);
  will-change: opacity, transform;
}
html.bsc-js:not(.bsc-lite) [data-bsc-reveal].is-in {
  opacity: 1;
  transform: none;
  will-change: auto;
}

/* ──────────────────────────────────────────────────────────────────
   8. RESPONSIVE
   ────────────────────────────────────────────────────────────────── */
@media (max-width: 1100px) { .bsc-shelf { --bsc-cols: 3; } }
@media (max-width: 720px)  { .bsc-shelf { --bsc-cols: 2; } }
@media (max-width: 420px)  { .bsc-shelf { --bsc-cols: 1; } }

@media (max-width: 720px) {
  .bsc-head-meta { flex-direction: column; gap: 6px; }
  .bsc-shelf     { margin-top: 36px; }
}

/* Touch devices never get a hover pill they can't trigger. */
@media (hover: none) {
  .bsc-open-pill { display: none; }
}

/* ──────────────────────────────────────────────────────────────────
   9. LITE MODE — mandatory strip rules
   `html.bsc-lite` is set by catalog.js when the device is weak
   (low core count / low memory / save-data / weak GPU / measured
   low FPS) or the user asked for reduced motion. EVERY effect above
   that costs compositing must be neutralised here.
   ────────────────────────────────────────────────────────────────── */
html.bsc-lite .bsc-modal {
  -webkit-backdrop-filter: none;
          backdrop-filter: none;
  background: rgba(10, 10, 15, 0.97);   /* solid-ish fallback */
}
html.bsc-lite .bsc-modal-close,
html.bsc-lite .bsc-badge {
  -webkit-backdrop-filter: none;
          backdrop-filter: none;
}
html.bsc-lite .bsc-badge { background: rgba(10, 10, 20, 0.9); }

html.bsc-lite .bsc-badge-dot { animation: none; }

html.bsc-lite .bsc-cover,
html.bsc-lite .bsc-cover-img,
html.bsc-lite .bsc-cover-art,
html.bsc-lite .bsc-cover-img img,
html.bsc-lite .bsc-open-pill {
  transition: none !important;
  transform: none !important;
}
html.bsc-lite .bsc-cover:hover .bsc-cover-img img { transform: none; }

/* Keep the affordance, drop the animation. */
html.bsc-lite .bsc-cover:hover .bsc-open-pill,
html.bsc-lite .bsc-cover:focus-visible .bsc-open-pill {
  opacity: 1;
  transform: translateX(-50%) !important;
}

html.bsc-lite .bsc-cover.is-soon[disabled] { filter: none; opacity: 0.7; }

/* Belt-and-braces: honour the OS setting even if the class is absent. */
@media (prefers-reduced-motion: reduce) {
  .bsc-badge-dot { animation: none; }
  .bsc-cover,
  .bsc-cover-img,
  .bsc-cover-art,
  .bsc-cover-img img,
  .bsc-open-pill,
  .bsc-modal,
  .bsc-modal-iframe,
  [data-bsc-reveal] {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* ══════════════════════════════════════════════════════════════════
   THEMING CHEAT-SHEET
   ------------------------------------------------------------------
   Drop this in the host stylesheet AFTER catalog.css:

     :root {
       --bsc-accent:     #1f6feb;
       --bsc-accent-rgb: 31, 111, 235;   // must match, used in shadows
       --bsc-ink:        #0d1117;
       --bsc-sans:       "Inter", system-ui, sans-serif;
       --bsc-radius-md:  4px;            // squarer, more editorial
       --bsc-cols:       3;              // 3-up shelf
     }

   Dark host page? Also set:
     --bsc-ink: #f0ece4;
     --bsc-ink-60: rgba(240,236,228,0.6);
     --bsc-ink-15: rgba(240,236,228,0.15);
     --bsc-ink-08: rgba(240,236,228,0.08);
   ══════════════════════════════════════════════════════════════════ */
