/* The library gallery (/gallery/, scripts/build-library-gallery.mjs). Loaded after /style.css and /assets/hub.css. */
.lib-visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap }

/* Previews: a read-only canvas the page script draws into (assets/library/gallery.js). Its box is fixed before it
   draws, so nothing moves when it does. */
.lib-preview { position: relative; margin: 0; aspect-ratio: 16 / 9; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #f3f1e4 }
.lib-preview .lib-canvas { position: absolute; inset: 0 }
.lib-preview .lib-canvas svg { display: block }
.lib-canvas[inert] .connector-handle { display: none }
.lib-preview figcaption { position: absolute; inset: auto 0 0; padding: .45rem .7rem; font-size: .8rem; line-height: 1.35; color: #44574b; background: color-mix(in srgb, #fffdf6 86%, transparent) }
/* A large preview (an item's page, a list's hero) has its caption under the picture, never over it. */
.lib-preview.large { aspect-ratio: auto; width: 100%; overflow: visible; border: 0; border-radius: 0; background: none }
.lib-preview.large .lib-canvas { position: relative; inset: auto; aspect-ratio: 4 / 3; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #f3f1e4 }
.lib-preview.large figcaption { position: static; padding: .55rem 0 0; background: none }
.lib-hero-link { display: block; color: inherit; text-decoration: none }

/* Filters */
.lib-browse { padding-bottom: clamp(1rem,2vw,1.6rem) }
.lib-filters { display: flex; flex-wrap: wrap; align-items: center; gap: .8rem 1.6rem; margin-bottom: 1rem }
.lib-kinds, .lib-chips { display: flex; flex-wrap: wrap; gap: .45rem }
.lib-kinds a, .lib-chips button { min-height: 44px; display: inline-flex; align-items: center; padding: .45rem .95rem; border: 1px solid var(--line); border-radius: 999px;
  font: 600 .92rem/1.2 inherit; color: var(--ink); background: #fffdf6; text-decoration: none; cursor: pointer }
.lib-kinds a[aria-current="page"], .lib-chips button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff }
.lib-kinds a:focus-visible, .lib-chips button:focus-visible { outline: 3px solid #f0cd7f; outline-offset: 2px }
.lib-note { max-width: 62rem; margin: 0; color: #44574b; line-height: 1.55 }
.lib-filter-empty { margin: .6rem 0 0 }

/* Lists */
.lib-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .6rem 1.4rem }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: clamp(1.1rem, 2.2vw, 1.8rem); margin: 0; padding: 0; list-style: none }
.lib-card { display: flex; flex-direction: column; gap: .45rem; min-width: 0; padding: .7rem .7rem 1rem; border: 1px solid var(--line); border-radius: 12px; background: #fffdf6 }
.lib-card[hidden] { display: none }
.lib-card > a { display: flex; flex-direction: column; gap: .7rem; color: inherit; text-decoration: none }
.lib-card > a:hover h3, .lib-card > a:focus-visible h3 { text-decoration: underline }
.lib-card h3 { margin: 0; font-size: clamp(1.3rem,1.7vw,1.6rem) }
.lib-summary { margin: 0; line-height: 1.45 }
.lib-meta { display: flex; flex-wrap: wrap; gap: .3rem .9rem; margin: auto 0 0; font-size: .85rem; color: #44574b }
.lib-from { margin: 0; font-size: .85rem }
.lib-group[hidden] { display: none }

/* An item's page */
.lib-item-hero .hub-hero-stage { gap: .8rem }
.lib-play { display: grid; gap: .6rem }
.lib-play-button { justify-self: start; min-height: 44px; padding: .6rem 1rem; border: 1px solid var(--ink); border-radius: 5px; background: #fffdf6; color: var(--ink); font: 600 1rem/1.2 inherit; cursor: pointer }
.lib-item-hero.playing .lib-preview { display: none }
.lib-player:empty { display: none }
/* The app's presentation player (assets/engine/presentation.mjs), framed as the Present hub frames it. */
.lib-player { position: relative; aspect-ratio: 4 / 3; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #f8f7ef }
.lib-player .presentation { height: 100%; display: grid; grid-template-rows: minmax(0,1fr) auto }
.lib-player .presentation-screen { position: relative; min-height: 0; overflow: hidden }
.lib-player .presentation-frame { position: absolute; inset: 0 }
.lib-player .presentation-frame > div { overflow: clip !important }
.lib-player .presentation-screen svg { pointer-events: none }
.lib-player .presentation nav { display: flex; gap: 5px; align-items: center; justify-content: center; padding: 6px; background: #f4f1e6; border-top: 1px solid #c3c9bb }
.lib-player .presentation nav button { min-width: 44px; min-height: 44px }
.lib-player .presentation output { font-variant-numeric: tabular-nums; min-width: 46px; text-align: center }
.lib-player .presentation nav.titled { min-width: 0 }
.lib-player .presentation nav.titled output { flex: 0 1 40ch; min-width: 0; padding-left: 4px; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
@media (prefers-reduced-motion: reduce) { .lib-player .presentation-screen * { transition: none !important; animation: none !important } }
.lib-offstage { position: fixed; left: -10000px; top: 0; width: 1200px; height: 800px; overflow: hidden }
.lib-about-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: clamp(1.6rem, 4vw, 4rem); align-items: start }
.lib-about-grid h3 { margin: 1.6rem 0 .6rem }
.lib-description { max-width: 46rem; line-height: 1.55 }
.lib-steps, .lib-notes { display: grid; gap: .55rem; margin: 0; padding-left: 1.3rem; line-height: 1.45 }
.lib-steps span { color: #44574b }
.lib-facts { margin: 0; border-bottom: 1px solid var(--line) }
.lib-facts > div { display: grid; grid-template-columns: 8.5rem 1fr; gap: .2rem .8rem; padding: .75rem 0; border-top: 1px solid var(--line) }
.lib-facts dt { font-weight: 700 }
.lib-facts dd { margin: 0 }
.lib-about .sc-caption small, .lib-about .sc-say small { display: block; font: 600 .78rem/1.4 ui-monospace,Menlo,monospace; color: #44574b }
.lib-about .sc-steps { padding-left: 1.3rem; line-height: 1.45 }

@media (max-width: 800px) {
  .lib-about-grid { grid-template-columns: 1fr }
  .lib-facts > div { grid-template-columns: 7rem 1fr }
}
