/* ═══════════════════════════════════════════════════════════════
   LIBRARY 🗂️ — ang komiks archive mo
   Mobile: filter rail + 2-col tilted card wall.
   Desktop: spread — index card (left page) / 4-col gallery wall (right page).
   ═══════════════════════════════════════════════════════════════ */

/* ── filter chips rail ── */
.lib-chips {
  display: flex; gap: 8px;
  overflow-x: auto; padding: 6px 2px 12px; margin-top: 4px;
  scrollbar-width: none;
}
.lib-chips::-webkit-scrollbar { display: none; }
.lib-chips .chip { flex: 0 0 auto; }

.lib-desk-note { display: none; }

/* ── generation sections ── */
.lib-sec { margin-bottom: 26px; }
.lib-sec-head { display: flex; align-items: baseline; gap: 8px; margin: 0 2px 10px; }
.lib-stamp { flex: 0 0 auto; font-size: 16px; }
.lib-sec-title {
  font-family: var(--f-head); font-weight: 700; font-size: 15px;
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lib-sec-date {
  margin-left: auto; flex: 0 0 auto;
  font-family: var(--f-mono); font-size: 11px; color: var(--newsprint-mute);
}

/* ── card wall ── */
.lib-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.lib-card {
  appearance: none; padding: 0; text-align: left; font: inherit; color: inherit;
  cursor: pointer; position: relative;
  background: var(--speech-fill);
  border: var(--border-ink); border-radius: var(--radius);
  box-shadow: var(--shadow-hard);
  overflow: hidden;
  transition: transform 0.16s, box-shadow 0.16s;
}
.lib-grid > .lib-card:nth-child(odd) { transform: rotate(-0.9deg); }
.lib-grid > .lib-card:nth-child(even) { transform: rotate(0.9deg); }
.lib-card:active { transform: translate(2px, 2px) rotate(0); box-shadow: 0 0 0 var(--panel-shadow); }
.lib-card-img { position: relative; background: var(--paper-sunk); }
.lib-card-img img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; }

/* corner emoji stamp */
.lib-stampcorner {
  position: absolute; top: 6px; right: 6px; z-index: 2;
  background: var(--paper-2); border: 2px solid var(--ink-line); border-radius: 8px;
  padding: 1px 5px; font-size: 13px; line-height: 1.3;
  transform: rotate(6deg);
  box-shadow: 1px 1px 0 var(--panel-shadow);
}

/* ── story cards ── */
.lib-play {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 46px; height: 46px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  border: 2.5px solid var(--ink-line);
  box-shadow: var(--shadow-hard);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--f-display); font-size: 19px; padding-left: 3px;
}
.lib-cover-pending { aspect-ratio: 3 / 4; min-height: 0; border: none; border-radius: 0; }
.lib-story-flag {
  position: absolute; left: 8px; bottom: 8px;
  background: var(--riso-yellow); border: 2px solid var(--ink-line); border-radius: 8px;
  font-family: var(--f-display); font-size: 11px; letter-spacing: 0.05em;
  padding: 1px 7px; transform: rotate(-3deg);
}
.lib-story-flag--fail { background: var(--riso-pink); color: #fff; }
.lib-story-flag--mp4 {
  left: auto; right: 8px; bottom: 8px;
  background: var(--riso-teal); color: #fff;
  font-size: 10px; transform: rotate(3deg);
}
.lib-card-foot { padding: 8px 10px; border-top: 2px solid var(--ink-line); background: var(--paper-2); }
.lib-card-title {
  font-family: var(--f-head); font-weight: 700; font-size: 13px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lib-card-meta { font-family: var(--f-mono); font-size: 10px; color: var(--newsprint-mute); margin-top: 1px; }

/* ── skeleton ── */
.lib-skel { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.lib-skel .gen-pending { aspect-ratio: 3 / 4; min-height: 0; }

/* ── empty / error state ── */
.lib-empty { padding: 34px 18px; margin-top: 8px; align-items: center; }
.lib-empty .speech { max-width: 260px; }

/* ── fullscreen detail overlay ── */
.lib-overlay {
  position: fixed; inset: 0; z-index: 80;
  background: var(--overlay-scrim);
  display: flex; flex-direction: column; align-items: center;
  padding: 26px 18px; overflow-y: auto;
}
.lib-detail {
  position: relative; margin: auto;
  width: 100%; max-width: 460px;
  display: flex; flex-direction: column; gap: 14px;
  animation: pop-up 0.28s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}
.lib-close {
  position: absolute; top: -12px; right: -8px; z-index: 3;
  width: 40px; height: 40px; border-radius: 50%; padding: 0;
  background: var(--riso-pink); color: #fff;
  border: var(--border-ink); box-shadow: var(--shadow-hard);
  font-family: var(--f-display); font-size: 16px;
  display: flex; align-items: center; justify-content: center;
}
.lib-close:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--ink); }
.lib-detail-frame {
  background: var(--speech-fill);
  border: var(--border-ink); border-radius: var(--radius);
  box-shadow: var(--shadow-harder);
  padding: 8px; transform: rotate(-0.6deg);
}
.lib-detail-frame img {
  width: 100%; max-height: 56vh; object-fit: contain;
  border-radius: 8px; background: var(--paper-sunk);
}
.lib-cap { font-size: 14px; margin-left: 6px; }
.lib-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 2px; }
.lib-actions .bubble-btn { font-size: 14px; letter-spacing: 0.05em; padding: 10px 8px; text-align: center; }
.lib-actions .bubble-btn::after { display: none; }
.lib-del { background: var(--speech-fill); color: var(--danger-ink); border: 2.5px solid var(--danger-ink); }

/* ═══ DESKTOP ≥1024px — index card left, gallery wall right ═══ */
@media (min-width: 1024px) {
  .spread.lib-spread { grid-template-columns: 290px 1fr; }
  .lib-chips { flex-direction: column; align-items: stretch; overflow: visible; padding: 8px 0 12px; }
  .lib-chips .chip { justify-content: flex-start; font-size: 14px; padding: 9px 16px; }
  .lib-desk-note { display: flex; align-items: flex-end; gap: 10px; margin-top: 20px; }
  .lib-desk-note .speech { font-size: 13px; }
  .lib-grid, .lib-skel { grid-template-columns: repeat(4, 1fr); gap: 14px; }
  .lib-sec { margin-bottom: 32px; }
  .lib-detail { max-width: 520px; }
  .lib-actions { grid-template-columns: repeat(4, 1fr); }
  .lib-actions .bubble-btn { font-size: 13px; padding: 10px 6px; }
}

/* hover lift (pointer devices only) */
@media (min-width: 1024px) and (hover: hover) {
  .lib-card:hover {
    transform: translateY(-5px) rotate(0);
    box-shadow: 6px 9px 0 var(--panel-shadow);
    z-index: 2;
  }
}
