/* ============================================================
   library-ledger.css - «คลังของฉัน» look (Owner direction 5 Oct 2026). VISUAL ONLY.
   Loaded by /pages/library.html AFTER css/pdf-library.css and overrides it; the reader
   (/pages/read.html) keeps pdf-library.css untouched. The page is only the signed-in shelf of OWNED
   books (read button only) + a collapsible «จัดการเครื่อง»; the storefront moved to /pages/shop.
   Every behaviour from #1242/#1248/#1249 (server-authoritative ownership, ?purchase=success polling,
   device limit, no download/print, no innerHTML) lives in js/library-page.js + js/pdf-library-common.js.
   Brand contract: tokens.css only, white / black - NO brand red in text or icons (Owner direction).
   Mobile and desktop are different layouts:
     mobile  · owned books as row-cards (cover | title | read), devices in a collapsed card
     ≥900px  · cover grid, devices card under it
   ============================================================ */

body#library-page .lib-shell { max-width: 1120px; padding-top: calc(var(--lib-chrome) + 24px); }

body#library-page .lib-hero { padding: 4px 0 0; border-bottom: 0; margin-bottom: 18px; }
body#library-page .lib-hero h1 { font-size: clamp(30px, 7.4vw, 42px); margin-bottom: 0; }
body#library-page .lib-section { margin-bottom: 20px; }

/* focus rings, spinner, notices: black, never red */
body#library-page .lib-btn:focus-visible, body#library-page .lib-devices-details > summary:focus-visible,
body#library-page .lib-shell a:focus-visible { outline: 3px solid var(--heading); outline-offset: 2px; }
body#library-page .lib-spinner { border-top-color: var(--heading); }
body#library-page .lib-notice { border-radius: 14px; margin: 0 0 20px; }
body#library-page .lib-notice-success { border-color: var(--heading); background: var(--ink); }
body#library-page .lib-notice-error { border-color: var(--line-strong); background: var(--ink-2); }
body#library-page .lib-callout { border-radius: 16px; }
body#library-page .lib-btn { border-radius: 12px; }

/* ── owned books: row-cards (mobile) ───────────────────────── */
body#library-page .lib-shelf { margin: 0; padding: 0; display: grid; grid-auto-flow: row; grid-auto-columns: auto; overflow: visible; scroll-snap-type: none; gap: 10px; }
body#library-page .lib-shelf-item {
  display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 14px; align-items: center;
  padding: 12px; border: 1px solid var(--line); border-radius: 16px; background: var(--ink);
}
body#library-page .lib-shelf-body { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 12px; align-items: center; }
body#library-page .lib-shelf-body > :not(.lib-btn) { grid-column: 1; }
body#library-page .lib-shelf-body > .lib-btn { grid-column: 2; grid-row: 1 / span 2; width: auto; }
body#library-page .lib-cover { border-radius: 4px 8px 8px 4px; }
/* reading is the black action */
body#library-page .lib-shelf .lib-btn-primary { background: var(--heading); border-color: var(--heading); color: var(--ink); }
body#library-page .lib-shelf .lib-btn-primary:hover { background: var(--text); border-color: var(--text); }

/* ── device line + collapsible «จัดการเครื่อง» ─────────────── */
body#library-page .lib-device-note { margin: 18px 0 0; font-size: 14px; line-height: 1.8; color: var(--muted); }
body#library-page #lib-devices-section { margin-top: 12px; }
body#library-page .lib-devices-details { background: var(--ink); border-color: var(--line-strong); border-radius: 16px; }
body#library-page .lib-devices-details > summary { font-size: 16px; display: flex; align-items: center; gap: 10px; pointer-events: auto; }
body#library-page .lib-devices-details > summary::after { content: "+"; margin-inline-start: auto; float: none; color: var(--muted); font: 400 20px/1 var(--ui); }
body#library-page .lib-devices-details[open] > summary::after { content: "-"; }
body#library-page .lib-devices-hint { font: 500 13px/1.3 var(--thai); color: var(--muted); }
body#library-page .lib-help { font-size: 13.5px; margin-top: 28px; }
body#library-page .lib-help a { color: var(--heading); text-decoration: underline; }

@media (min-width: 900px) {
  body#library-page .lib-shell { padding: calc(var(--lib-chrome) + 40px) 32px 96px; }
  body#library-page .lib-shelf { grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 26px 22px; }
  body#library-page .lib-shelf-item { grid-template-columns: 1fr; padding: 0; border: 0; background: none; gap: 10px; align-items: start; }
  body#library-page .lib-shelf-body { display: flex; flex-direction: column; align-items: stretch; gap: 8px; }
  body#library-page .lib-shelf-body > .lib-btn { width: 100%; }
  body#library-page .lib-device-note, body#library-page #lib-devices-section { max-width: 560px; }
}
