/* ═══════════════════════════════════════════════════════════════════════════
   The widget library.

   ⚠ THIS IS A SHELF, NOT A DATABASE. A flat grid with three lines of metadata
   under every cell reads as a table of contents; what it should read as is a
   room with things in it. So: a masthead with a sentence in it, sections with
   real headings, cards with air, and the metadata that belongs to ONE widget
   moved into that widget's own sheet rather than repeated sixty-nine times.

   ⚠ AND `.chip` MEANT TWO THINGS. app.css's composer chip is a fixed 56pt
   square with overflow:hidden, so every filter here rendered as a 56px box
   with its name clipped inside it. The filters are `.cchip` / `.pchip`.
   ═══════════════════════════════════════════════════════════════════════════ */

body.lib {
  --ink: #f2f1ee;
  --dim: rgba(238,238,234,.60);
  --faint: rgba(238,238,234,.36);
  --line: rgba(255,255,255,.10);
  --card: rgba(255,255,255,.035);
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(120% 90% at 18% -8%, #17171b 0%, #0b0b0d 62%);
  color: var(--ink);
  font: 400 15px/1.5 Selecta, ui-sans-serif, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ── the masthead ───────────────────────────────────────────────────────── */
#lhead {
  position: sticky; top: 0; z-index: 40;
  padding: 34px 34px 0;
  background: linear-gradient(#0b0b0d 62%, rgba(11,11,13,.86) 88%, rgba(11,11,13,0));
  backdrop-filter: blur(14px) saturate(1.2);
}
#lhead .mast { display: flex; gap: 18px; align-items: flex-start; max-width: 1560px; margin: 0 auto 22px; }
#lhead .back {
  flex: none; width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--line); background: rgba(255,255,255,.05);
  display: grid; place-items: center; margin-top: 4px;
}
#lhead .back::before {
  content: ''; width: 9px; height: 9px; margin-left: 3px;
  border-left: 1.6px solid var(--ink); border-bottom: 1.6px solid var(--ink);
  transform: rotate(45deg);
}
#lhead .back:hover { background: rgba(255,255,255,.10); }
#lhead h1 { margin: 0; font-size: 30px; font-weight: 500; letter-spacing: -.028em; }
#lhead .ti p { margin: 6px 0 0; max-width: 62ch; color: var(--dim); font-size: 14.5px; }
#lhead .ti p b { font-weight: 500; color: var(--ink); }
#lhead .ti a { color: var(--ink); text-decoration-color: rgba(255,255,255,.3); text-underline-offset: 3px; }

/* ⚠ ONE ROW OF THE PAGE'S OWN CONTROLS, then the two filter rows. Search and
   size are about HOW you are looking; kind and person are about WHAT. */
#lhead .tools { display: flex; gap: 12px; align-items: center; max-width: 1560px; margin: 0 auto 12px; }
.find { flex: 1; max-width: 340px; display: block; }
.find input {
  width: 100%; box-sizing: border-box; height: 38px; padding: 0 15px;
  border-radius: 19px; border: 1px solid var(--line);
  background: rgba(255,255,255,.05); color: var(--ink);
  font: inherit; font-size: 14px; outline: none;
}
.find input::placeholder { color: var(--faint); }
.find input:focus { border-color: rgba(255,255,255,.26); background: rgba(255,255,255,.08); }
.seg { display: flex; gap: 2px; padding: 3px; border-radius: 19px; border: 1px solid var(--line); background: rgba(255,255,255,.04); }
.seg button {
  border: 0; background: none; color: var(--dim); font: inherit; font-size: 13px;
  padding: 0 14px; height: 30px; border-radius: 16px; cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--ink); color: #0b0b0d; font-weight: 500; }

#cats, #whos {
  display: flex; gap: 7px; flex-wrap: wrap; max-width: 1560px; margin: 0 auto;
  padding-bottom: 10px;
}
#whos { padding-bottom: 20px; }
.cchip, .pchip {
  display: inline-flex; align-items: center; gap: 7px;
  height: 32px; padding: 0 13px; border-radius: 16px;
  border: 1px solid var(--line); background: rgba(255,255,255,.035);
  color: var(--dim); font: inherit; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.cchip em, .pchip em { font-style: normal; color: var(--faint); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.cchip:hover, .pchip:hover { background: rgba(255,255,255,.08); color: var(--ink); }
.cchip[aria-pressed="true"], .pchip[aria-pressed="true"] {
  background: var(--ink); border-color: var(--ink); color: #0b0b0d; font-weight: 500;
}
.cchip[aria-pressed="true"] em, .pchip[aria-pressed="true"] em { color: rgba(11,11,13,.5); }
.pchip .orb {
  width: 13px; height: 13px; border-radius: 50%; flex: none;
  background: linear-gradient(140deg, var(--o1), var(--o2));
}

/* ── the shelf ──────────────────────────────────────────────────────────── */
#grid { max-width: 1560px; margin: 0 auto; padding: 6px 34px 90px; }
.sec { margin: 0 0 34px; }
.sec > h2 {
  margin: 0 0 14px; font-size: 13px; font-weight: 500;
  letter-spacing: .16em; text-transform: uppercase; color: var(--faint);
  display: flex; align-items: baseline; gap: 10px;
}
.sec > h2::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.sec > h2 i { font-style: normal; font-variant-numeric: tabular-nums; }
.row { display: grid; gap: 22px 20px; grid-template-columns: repeat(auto-fill, minmax(var(--col, 158px), 1fr)); }
body.lib[data-size="56"] .row { --col: 92px; gap: 18px 16px; }
body.lib[data-size="240"] .row { --col: 240px; gap: 26px 22px; }

.lw { display: block; border: 0; background: none; padding: 0; text-align: left; cursor: pointer; color: inherit; font: inherit; }
.lw .hold {
  display: block; position: relative; width: 100%; aspect-ratio: 1;
  border-radius: 22px; overflow: hidden;
  box-shadow: 0 1px 0 rgba(255,255,255,.07) inset, 0 10px 26px rgba(0,0,0,.44);
  transition: transform .18s cubic-bezier(.2,.7,.3,1), box-shadow .18s;
}
body.lib[data-size="56"] .lw .hold { border-radius: 15px; }
.lw:hover .hold { transform: translateY(-3px); box-shadow: 0 1px 0 rgba(255,255,255,.10) inset, 0 16px 34px rgba(0,0,0,.55); }
.lw:focus-visible .hold { outline: 2px solid var(--ink); outline-offset: 3px; }
.lw .hold .field { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.lw cite { display: block; margin: 9px 0 0; font-style: normal; font-size: 13.5px; font-weight: 500; letter-spacing: -.012em; }
.lw small { display: block; margin-top: 1px; font-size: 11.5px; color: var(--faint); }
body.lib[data-size="56"] .lw cite { font-size: 12px; margin-top: 7px; }
body.lib[data-size="56"] .lw small { display: none; }
.none { color: var(--dim); padding: 40px 0 90px; font-size: 15px; }

#lfoot {
  max-width: 1560px; margin: 0 auto; padding: 0 34px 60px;
  color: var(--faint); font-size: 12.5px;
}

/* ── one widget, up close ───────────────────────────────────────────────── */
#detail { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 24px; }
#detail[hidden] { display: none; }
#detail .scrim { position: absolute; inset: 0; border: 0; background: rgba(6,6,8,.72); backdrop-filter: blur(10px); cursor: default; }
#detail .card {
  position: relative; display: grid; grid-template-columns: 288px minmax(0, 1fr);
  gap: 30px; align-items: start;
  max-width: 760px; width: 100%; padding: 30px;
  border-radius: 30px; border: 1px solid rgba(255,255,255,.10);
  background: linear-gradient(150deg, #1a1a1f, #121216);
  box-shadow: 0 40px 90px rgba(0,0,0,.62);
}
#detail .big { position: relative; width: 240px; height: 240px; border-radius: 32px; overflow: hidden; box-shadow: 0 14px 34px rgba(0,0,0,.5); }
#detail .big .field { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
#detail .meta { min-width: 0; }
#detail .from { display: block; font-size: 11.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--faint); }
#detail [data-name] { display: block; margin: 5px 0 0; font-size: 27px; font-weight: 500; letter-spacing: -.028em; }
#detail .prompt { margin: 12px 0 0; font-size: 15px; line-height: 1.55; color: var(--dim); }
#detail h3 { margin: 22px 0 8px; font-size: 11.5px; font-weight: 400; letter-spacing: .14em; text-transform: uppercase; color: var(--faint); }
#detail .vars { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 18px; }
.vchip {
  border: 1px solid var(--line); background: rgba(255,255,255,.04); color: var(--dim);
  font: inherit; font-size: 12.5px; padding: 0 13px; height: 31px; border-radius: 16px; cursor: pointer;
}
.vchip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #0b0b0d; font-weight: 500; }
#detail .adds { display: flex; flex-direction: column; gap: 5px; }
#detail .adds span { font-size: 13.5px; color: var(--dim); padding-left: 15px; position: relative; }
#detail .adds span::before { content: '+'; position: absolute; left: 0; color: var(--faint); }
#detail .owners { display: flex; align-items: center; gap: 6px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--faint); }
#detail .owners .orb { width: 15px; height: 15px; border-radius: 50%; background: linear-gradient(140deg, var(--o1), var(--o2)); }
#detail .owners span { margin-left: 5px; }
#detail .shut {
  position: absolute; right: 14px; top: 14px; z-index: 2; width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid var(--line); background: rgba(255,255,255,.06); cursor: pointer;
  display: grid; place-items: center;
}
#detail .shut::before, #detail .shut::after {
  content: ''; position: absolute; width: 13px; height: 1.5px; background: var(--ink); border-radius: 1px;
}
#detail .shut::before { transform: rotate(45deg); }
#detail .shut::after { transform: rotate(-45deg); }

@media (max-width: 820px) {
  #lhead { padding: 22px 18px 0; }
  #lhead h1 { font-size: 23px; }
  #lhead .ti p { font-size: 13.5px; }
  #grid, #lfoot { padding-left: 18px; padding-right: 18px; }
  .row { --col: 132px; gap: 18px 14px; }
  #detail .card { grid-template-columns: minmax(0, 1fr); gap: 20px; padding: 22px; }
  #detail .big { width: 100%; height: auto; aspect-ratio: 1; }
}
@media (prefers-reduced-motion: reduce) { .lw .hold { transition: none; } }
