/* ================================================================ LIBRARY
   The homepage's catalog as a page: a headline, the prompt-bar search, filters as outline pills (the chosen one
   ink), and a grid of dark 16:9 frames, live and fitted to their content, with the name and category under each.
   Zoom sets the columns (library.js): the readout is the size a 1920 px frame is drawn at. */

.library { width: min(1200px, 100% - 40px); margin: 0 auto; padding: 0 0 120px; }

/* ---------------------------------------------------------------- header */
.lib-head { padding: clamp(40px, 8vh, 72px) 0 30px; text-align: center; }
.lib-head .eyebrow { margin-bottom: 14px; }
.lib-h1 { margin: 0 auto; max-width: 18ch; text-wrap: balance; font: 700 clamp(32px, 4.4vw, 54px)/1.05 var(--font); letter-spacing: -.035em; }
.lib-head .lede { margin: 16px auto 0; max-width: 50ch; }

/* ---------------------------------------------------------------- search: the homepage's prompt bar */
.lib-search { margin: 0 auto; }
.lib-search kbd { flex: none; margin-right: 10px; transition: opacity var(--dur-fast); }
.lib-search input:focus ~ kbd, .lib-search input:not(:placeholder-shown) ~ kbd { opacity: 0; }
input.search::-webkit-search-cancel-button {
  -webkit-appearance: none; appearance: none; width: 16px; height: 16px; margin-right: 6px; cursor: pointer; background: var(--ink-3);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14'%3E%3Cpath d='M3 3l8 8M11 3l-8 8' stroke='black' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* ---------------------------------------------------------------- filters: outline pills, the chosen one ink */
.lib-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin: 34px 0 0; padding: 0 0 18px; border-bottom: 1px solid var(--line); }
.lib-tools .seg.pills { gap: 8px; padding: 0; background: none; border: 0; border-radius: 0; }
.lib-tools .seg.pills span {
  padding: 0 15px; height: 38px; display: grid; place-items: center; border-radius: 999px;
  border: 1px solid var(--line-3); background: #fff; color: var(--ink); font: 500 14px/1 var(--font);
  transition: border-color var(--dur-fast), background-color var(--dur-fast), color var(--dur-fast);
}
.lib-tools .seg.pills label:hover span { border-color: var(--ink); }
.lib-tools .seg.pills input:checked + span { background: var(--ink); border-color: var(--ink); color: #fff; box-shadow: none; }
.cat-select {
  flex: 0 1 auto; width: auto; min-width: 170px; height: 38px; padding-left: 15px; border-radius: 999px;
  border-color: var(--line-3); font: 500 14px/1 var(--font);
}
.cat-select:hover { border-color: var(--ink); }
.library .zoom { display: flex; align-items: center; gap: 4px; flex: none; margin-left: auto; }
.library .zoom .icon-btn { width: 32px; height: 32px; color: var(--ink-2); }
.library .zoom .icon-btn:hover:not(:disabled) { color: var(--ink); }
.library .zoom-val { display: none; min-width: 44px; text-align: center; color: var(--ink-3); font: 500 13px/1 var(--font); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- the grid */
.lib-meta { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 18px 0 26px; }
.lib-count { margin: 0; color: var(--ink-3); font: 500 14px/1.2 var(--font); }
.lib-count .all-live::before { content: ''; display: inline-block; width: 6px; height: 6px; margin: 0 9px 2px 0; border-radius: 50%; background: var(--pink); }

.wall {
  --cols: 4; --gx: 24px;
  display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: calc(var(--gx) + 12px) var(--gx);
  align-items: start;
}

/* a group label across the grid: "Featured" (premium 3D / VFX) leads, "More templates" follows */
.wall-sep { grid-column: 1 / -1; display: flex; align-items: baseline; gap: 12px; min-width: 0; padding: 0 0 2px; }
.wall-sep ~ .wall-sep { margin-top: 30px; }
.wall-sep-name { color: var(--ink); white-space: nowrap; font: 650 19px/1.2 var(--font); letter-spacing: -.015em; }
.wall-sep[data-id="__sep-featured"] .wall-sep-name { color: var(--pink); font: 600 14px/1.2 var(--font); letter-spacing: .01em; }
.wall-sep-note { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-3); font: 450 14px/1.2 var(--font); }
.wall-sep[data-id="__sep-featured"] .wall-sep-note { color: var(--ink-2); }

/* a tile: the dark frame, then its name and category */
.tile { position: relative; display: block; min-width: 0; color: inherit; text-decoration: none; outline: none; -webkit-tap-highlight-color: transparent; }
.tile-frame { position: relative; }
.tile-media {
  position: relative; aspect-ratio: 16 / 9; overflow: hidden; border-radius: var(--frame-r); background-color: var(--frame);
  box-shadow: var(--frame-shadow-sm); transition: box-shadow .35s var(--ease), transform .35s var(--ease);
}
.tile:hover .tile-media, .tile:focus-visible .tile-media { transform: translateY(-3px); box-shadow: var(--frame-shadow); }
.tile:focus-visible .tile-media { outline: 2px solid var(--pink); outline-offset: 3px; }
.tile:active .tile-frame { transform: scale(.985); transition: transform .12s var(--ease); }
.tile-meta { display: block; margin: 13px 2px 0; }
.tile-row { display: flex; align-items: baseline; gap: 10px; }
.tile-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); font: 600 15.5px/1.3 var(--font); letter-spacing: -.01em; }
.tile-open {
  margin-left: auto; flex: none; color: var(--pink); font: 600 13.5px/1.3 var(--font);
  opacity: 0; transform: translateX(-4px); transition: opacity var(--dur-fast), transform var(--dur) var(--ease);
}
.tile:hover .tile-open, .tile:focus-visible .tile-open { opacity: 1; transform: none; }
.tile-cat { display: block; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); font: 450 14px/1.35 var(--font); }
.wall.dense .tile-cat { display: none; }
.wall.dense .tile-name { font-size: 13.5px; }
.wall.dense .tile-meta { margin-top: 9px; }

/* the new template Opus 5.5 would make: an empty dark frame, a dashed frame being dragged out, its cursor */
.library .gen-frame {
  position: relative; aspect-ratio: 16 / 9; overflow: hidden; container-type: inline-size; border-radius: var(--frame-r);
  background: var(--frame); box-shadow: var(--frame-shadow-sm); transition: box-shadow .35s var(--ease), transform .35s var(--ease);
}
.gen-tile:hover .gen-frame, .gen-tile:focus-visible .gen-frame { transform: translateY(-3px); box-shadow: var(--frame-shadow); }
.library .drag {
  position: absolute; left: 11%; top: 16%; width: 62%; height: 58%; display: grid; place-items: center;
  border: 1.5px dashed rgba(255, 61, 139, .75); border-radius: 6px; background: rgba(255, 61, 139, .08);
}
.library .drag-copy { display: grid; gap: .5em; padding: 0 8%; text-align: center; }
.library .drag-copy strong { color: #fff; font: 650 clamp(12px, 6.6cqw, 24px)/1.05 var(--font); letter-spacing: -.02em; text-wrap: balance; }
.library .drag-copy span { color: rgba(255, 255, 255, .62); font: 500 clamp(10px, 3.9cqw, 14px)/1.2 var(--font); }
.library .gen-cursor { position: absolute; left: 100%; top: 100%; display: flex; align-items: flex-start; pointer-events: none; }
.library .gen-cursor .cur { display: block; width: 16px; height: 21px; margin: -2px 0 0 -2px; filter: drop-shadow(0 1px 1.5px rgba(0, 0, 0, .5)); }
.library .gen-cursor .cur svg { display: block; width: 100%; height: 100%; }
.library .gen-cursor .cur path { fill: #fff; stroke: var(--ink); stroke-width: 1.1; stroke-linejoin: round; }
.library .gen-cursor .cursor-tag { margin: 15px 0 0 -3px; font-size: clamp(9.5px, 3.8cqw, 12px); }
/* hover: Opus drags the frame out again, corner to corner, and the words settle into it */
.gen-tile:hover .drag, .gen-tile:focus-visible .drag { animation: libDrag .9s var(--ease-io) both; }
.gen-tile:hover .drag-copy, .gen-tile:focus-visible .drag-copy { animation: libSettle .45s .7s var(--ease) both; }
@keyframes libDrag { from { width: 0; height: 0; } }
@keyframes libSettle { from { opacity: 0; } }
.wall.dense .drag-copy span { display: none; }

/* ---------------------------------------------------------------- narrower screens */
@media (max-width: 760px) {
  .library { width: calc(100% - 32px); padding-bottom: 72px; }
  .lib-head { padding: 36px 0 24px; }
  .lib-tools { gap: 8px; margin-top: 22px; }
  .lib-tools .seg.pills { gap: 6px; }
  .lib-tools .seg.pills span { height: 34px; padding: 0 12px; font-size: 13.5px; }
  .cat-select { flex: 1 1 150px; min-width: 0; height: 34px; font-size: 13.5px; }
  .library .zoom-val { display: none; }
  .lib-search kbd { display: none; }
}
