/* ============================================================================
   OmniSolver Models · library.css — owner's model grid (route /library).
   Dark-premium "3D foundry". NO rendered models, NO thumbnails: each model is a
   metric-forward .asset-card with the shared .asset-viz tile (gradient + wireframe
   CUBE GLYPH + .corner polycount), Skills-style metric chips, status badges,
   glowing CTAs, scroll-reveal + pointer-tilt.
   Load order: tokens.css -> base.css -> library.css. TOKENS ONLY.
   ============================================================================ */

.lib { padding-top: var(--s-9); padding-bottom: var(--s-11); position: relative; }

/* ---- header (hero band) ---------------------------------------------------- */
.lib-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: var(--s-5); flex-wrap: wrap; margin-bottom: var(--s-8);
}
.lib-head .eyebrow { margin-bottom: 2px; }
.lib-head h1 {
  margin: 0; font-size: var(--fs-3xl); letter-spacing: var(--tracking-tight);
  background: var(--grad-text); -webkit-background-clip: text; background-clip: text;
  color: transparent;
}
.lib-head p { margin: 8px 0 0; max-width: 58ch; color: var(--text-2); font-size: var(--fs-md); }
.lib-head .btn-primary { align-self: flex-end; }

/* ---- toolbar (glass) ------------------------------------------------------- */
.lib-toolbar {
  display: flex; align-items: flex-end; gap: var(--s-4);
  flex-wrap: wrap; margin-bottom: var(--s-7);
  background: var(--glass-bg); -webkit-backdrop-filter: blur(var(--glass-blur));
  backdrop-filter: blur(var(--glass-blur)); border: 1px solid var(--glass-border);
  border-radius: var(--r-lg); box-shadow: var(--sh-2), var(--sh-inset);
  position: relative;
}
.lib-toolbar::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 1px;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  background: linear-gradient(90deg, transparent, var(--glass-hi), transparent);
}
.lib-search { position: relative; flex: 1 1 300px; min-width: 0; }
.lib-search .icon {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); pointer-events: none; width: 18px; height: 18px;
}
.lib-search .field {
  padding-left: 40px; background: var(--surface-ink);
}
.lib-search .field:focus { box-shadow: var(--ring); }
.lib-filter { flex: 0 0 auto; min-width: 190px; }
.lib-filter .lbl { margin-bottom: 5px; color: var(--text-muted); }

/* ---- grid ------------------------------------------------------------------ */
.lib-grid {
  grid-template-columns: repeat(auto-fill, minmax(264px, 1fr));
  align-items: start; gap: var(--s-5);
}

/* ---- card (dark glass, lift + teal glow) ----------------------------------- */
.lib-card {
  display: flex; flex-direction: column; overflow: hidden;
  border-radius: var(--r-lg); padding: 14px; color: inherit;
}
.lib-card:hover { color: inherit; }

/* asset-viz tile lives at the top of the card — square corners flush to card pad.
   Status badge floats on the tile (top-left); the .corner polycount is bottom-right
   (provided by .asset-viz in base.css). */
.lib-card .asset-viz { width: 100%; }
.lib-card .asset-viz .badge {
  position: absolute; top: 10px; left: 10px; z-index: 2;
  box-shadow: var(--sh-1); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}

/* body */
.lib-card .body {
  padding: var(--s-4) 2px 2px; display: flex; flex-direction: column;
  gap: var(--s-3); flex: 1;
}
.lib-card .name-row { display: flex; align-items: flex-start; gap: var(--s-2); }
.lib-card .name {
  font-weight: 650; font-size: var(--fs-md); line-height: var(--lh-snug);
  color: var(--text); margin: 0; flex: 1; min-width: 0; letter-spacing: -0.01em;
  overflow: hidden; text-overflow: ellipsis; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.lib-card:hover .name { color: var(--teal-hi); }
.lib-card .btn-rename { flex: none; opacity: 0; transition: opacity var(--t-fast); }
.lib-card:hover .btn-rename, .lib-card:focus-within .btn-rename { opacity: 1; }

/* metric chips — teal data */
.lib-card .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.lib-card .chips .chip .icon { width: 13px; height: 13px; }

/* actions */
.lib-card .actions {
  display: flex; flex-wrap: wrap; gap: var(--s-2);
  margin-top: auto; padding-top: var(--s-3);
  border-top: 1px solid var(--line-soft);
}
.lib-card .actions .btn { flex: 1 1 auto; }
.lib-card .actions .btn-open { flex-basis: 100%; }
.lib-card .actions .btn-icon { flex: 0 0 auto; }

/* failed card hint */
.lib-card .fail-note {
  font-size: var(--fs-xs); color: var(--danger);
  display: flex; align-items: center; gap: 5px;
}
.lib-card .fail-note .icon { width: 14px; height: 14px; }

/* ---- skeleton cards (loading) --------------------------------------------- */
.lib-sk-card { border-color: var(--line-soft); box-shadow: var(--sh-1); }
.lib-sk-card .sk-viz { aspect-ratio: 4 / 3; border-radius: var(--r-md); }
.lib-sk-card .body { gap: 0; }
.lib-sk-card .sk-line { height: 12px; border-radius: var(--r-xs); margin-bottom: 10px; }
.lib-sk-card .sk-line.w-60 { width: 60%; } .lib-sk-card .sk-line.w-40 { width: 40%; }

/* ---- empty state (dark, glowing CTA) -------------------------------------- */
.lib-grid .empty {
  position: relative;
  background: var(--glass-bg); -webkit-backdrop-filter: blur(var(--glass-blur));
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border); border-radius: var(--r-xl);
  box-shadow: var(--sh-2), var(--sh-inset);
  padding: var(--s-11) var(--s-6);
}
.lib-grid .empty::before {
  content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none;
  border-radius: var(--r-xl);
  background: radial-gradient(420px 240px at 50% -10%, rgba(34,199,182,0.12), transparent 70%);
}
.lib-grid .empty > * { position: relative; z-index: 1; }
.lib-grid .empty .empty-glyph {
  width: 64px; height: 64px; margin: 0 auto var(--s-4); color: var(--teal);
  opacity: .9; filter: drop-shadow(0 0 22px rgba(34,199,182,0.32));
}
.lib-grid .empty .icon {
  width: 52px; height: 52px; stroke-width: 1.2; color: var(--teal);
  margin-bottom: var(--s-4);
  filter: drop-shadow(0 0 22px rgba(34,199,182,0.32));
}
.lib-grid .empty p {
  color: var(--text-2); max-width: 46ch; margin: 0 auto var(--s-5);
  font-size: var(--fs-md);
}
.lib-grid .empty .btn-primary { box-shadow: var(--glow-teal); }

/* ---- delete-confirm preview inside modal (abstract viz, NO thumbnail) ------ */
.del-preview {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3); border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--surface-2); margin-bottom: var(--s-4);
}
.del-preview .del-viz {
  width: 64px; height: 48px; flex: none; aspect-ratio: auto; border-radius: var(--r-sm);
}
.del-preview .del-viz .glyph { width: 50%; height: 50%; }

/* ---- responsive ------------------------------------------------------------ */
@media (max-width: 760px) {
  .lib-head h1 { font-size: var(--fs-2xl); }
}
@media (max-width: 560px) {
  .lib { padding-top: var(--s-7); }
  .lib-head { align-items: stretch; }
  .lib-head .btn-primary { width: 100%; align-self: stretch; }
  .lib-toolbar { padding: var(--s-4); }
  .lib-grid { grid-template-columns: 1fr; }
}
@media (max-width: 360px) {
  .lib-card .actions .btn-open { flex-basis: 100%; }
  .lib-head h1 { font-size: var(--fs-xl); }
}
