/* Content library pages (Saffron redesign, group A):
   article, mentor_article, current_affairs, ca_note, handout, study_material,
   announcement, book_listing — student lists / detail pages and staff create/edit forms.
   Colours only through var(--vr-…) so dark mode works. Loaded after vr-core.css. */

/* ---------- Breadcrumb + page head ---------- */
.cl-crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 4px; font-size: 13px; color: var(--vr-muted); }
.cl-crumbs a { color: var(--vr-muted); text-decoration: none; }
.cl-crumbs a:hover { color: var(--vr-accent-ink); text-decoration: underline; }
.cl-crumbs [aria-current="page"] { color: var(--vr-ink-2); font-weight: 600; max-width: 32ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cl-head-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.cl-req { color: var(--vr-bad); }
.cl-opt { color: var(--vr-muted); font-weight: 500; }

/* ---------- Month / subject tiles ---------- */
.cl-tiles { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.cl-tile {
  display: flex; align-items: center; gap: 14px; min-height: 84px; box-sizing: border-box; padding: 16px 18px;
  border-radius: var(--vr-r-2); background: var(--vr-card); box-shadow: var(--vr-shadow);
  color: var(--vr-ink) !important; text-decoration: none !important; border: 1px solid transparent;
}
.cl-tile:hover { border-color: var(--vr-accent); }
.cl-tile:hover .cl-tile__go { color: var(--vr-accent-ink); transform: translateX(2px); }
.cl-tile__icon { flex: none; width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; background: var(--vr-accent-soft); color: var(--vr-accent-ink); }
.cl-tile__text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.cl-tile__title { font-size: 15px; font-weight: 800; letter-spacing: .01em; line-height: 1.3; text-transform: uppercase; overflow-wrap: anywhere; }
.cl-tile__meta { font-size: 12px; color: var(--vr-muted); }
.cl-tile__go { flex: none; color: var(--vr-muted); transition: transform .15s; }
.cl-tiles--info .cl-tile__icon { background: var(--vr-info-soft); color: var(--vr-info); }
.cl-tiles--good .cl-tile__icon { background: var(--vr-good-soft); color: var(--vr-good); }
.cl-tiles--maroon .cl-tile__icon { background: var(--vr-maroon-soft); color: var(--vr-maroon); }
.cl-tiles--purple .cl-tile__icon { background: var(--vr-purple-soft); color: var(--vr-purple); }
@media (prefers-reduced-motion: reduce) { .cl-tile__go { transition: none; } }

.cl-empty { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 36px 18px; }
.cl-empty img { width: 160px; max-width: 60%; height: auto; opacity: .9; }
.cl-empty p { margin: 0; max-width: 46ch; font-size: 14px; }

/* ---------- Date-grouped streams (AJAX components) ---------- */
.cl-stream { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.cl-day-group { display: flex; flex-direction: column; gap: 14px; }
.cl-day-group:not(:has(.vr-post)) { display: none; }
.cl-day { display: flex; align-items: center; gap: 8px; margin: 6px 0 0; font-size: 14px; font-weight: 800; color: var(--vr-ink-2); }
.cl-day svg { color: var(--vr-accent-ink); }
.cl-day::after { content: ""; flex: 1; height: 1px; background: var(--vr-line); }
.cl-load-more[hidden] { display: none !important; }
.vr-post:target, .vr-post.is-target { box-shadow: 0 0 0 2px var(--vr-accent), var(--vr-shadow); }
.vr-post { scroll-margin-top: calc(var(--vr-topbar-h) + 16px); }
.cl-note-box { border-left: 3px solid var(--vr-info); }

/* ---------- Detail pages ---------- */
.cl-detail { gap: 18px; }
.cl-detail__head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px; }
.cl-detail__title { margin: 0; font-size: 28px; line-height: 1.25; font-weight: 800; letter-spacing: -0.015em; color: var(--vr-ink); overflow-wrap: anywhere; }
.cl-detail__sub { margin: 0; font-size: 18px; line-height: 1.45; font-weight: 600; color: var(--vr-ink-2); }
.cl-detail__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; font-size: 13px; color: var(--vr-muted); }
.cl-detail__meta span { display: inline-flex; align-items: center; gap: 6px; }
.cl-detail__actions { display: flex; flex-wrap: wrap; gap: 8px; }
.cl-detail__actions form { margin: 0; }
.cl-detail__media { margin: 0; border-radius: 16px; overflow: hidden; background: var(--vr-card-2); }
.cl-detail__media img { display: block; width: 100%; height: auto; }
.cl-detail .vr-prose { font-size: 16px; line-height: 1.75; color: var(--vr-ink); }
.cl-detail .vr-prose h1, .cl-detail .vr-prose h2, .cl-detail .vr-prose h3 { line-height: 1.35; margin: 18px 0 8px; }
.cl-detail .vr-prose ul, .cl-detail .vr-prose ol { padding-left: 22px; }
.cl-source { font-size: 13px; color: var(--vr-muted); padding-top: 12px; border-top: 1px solid var(--vr-line); }
.cl-btn-danger { color: var(--vr-bad) !important; }
.cl-btn-danger:hover { background: var(--vr-bad-soft); }

.cl-latest { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.cl-latest a { display: flex; gap: 12px; align-items: flex-start; padding: 10px; border-radius: 12px; color: var(--vr-ink); text-decoration: none; }
.cl-latest a:hover { background: var(--vr-card-2); color: var(--vr-ink); text-decoration: none; }
.cl-latest a:hover strong { color: var(--vr-accent-ink); }
.cl-latest__icon { flex: none; width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; background: var(--vr-maroon-soft); color: var(--vr-maroon); background-size: cover; background-position: center; }
.cl-latest__text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.cl-latest__text strong { font-size: 13px; line-height: 1.4; }
.cl-latest__text small { font-size: 12px; color: var(--vr-muted); }
.cl-latest__text p { margin: 0; font-size: 12px; color: var(--vr-ink-2); }

/* ---------- Staff create / edit forms ---------- */
.cl-editor { padding: 26px 28px; }
.cl-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.cl-section-title { margin: 6px 0 0; padding-top: 18px; border-top: 1px solid var(--vr-line); font-size: 15px; font-weight: 800; color: var(--vr-ink); }
.cl-help { margin: 0; font-size: 12px; color: var(--vr-muted); }
.cl-editor textarea.vr-input { height: auto; min-height: 180px; padding: 12px 16px; line-height: 1.5; resize: vertical; }
.cl-editor select.vr-input { padding-right: 12px; }
.cl-editor .mce-tinymce { border-radius: 14px !important; overflow: hidden; border: 1.5px solid var(--vr-line-2) !important; box-shadow: none !important; }
.cl-editor .vr-field.has-error .mce-tinymce { border-color: var(--vr-bad) !important; }
.cl-checks { display: flex; flex-wrap: wrap; gap: 12px 28px; }
.cl-actions { display: flex; flex-direction: column; gap: 12px; padding-top: 18px; border-top: 1px solid var(--vr-line); }
.cl-actions .vr-submit { width: 100%; }

/* Upload widget (replaces script.js .file_upload_form) */
.cl-upload__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.cl-upload__list:empty { display: none; }
.cl-upload__item {
  display: flex; align-items: center; gap: 10px; min-height: 48px; box-sizing: border-box; padding: 8px 8px 8px 14px;
  border-radius: 12px; background: var(--vr-card-2); border: 1px solid var(--vr-line); font-size: 13px;
}
.cl-upload__item > svg { flex: none; color: var(--vr-accent-ink); }
.cl-upload__name { flex: 1; min-width: 0; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cl-upload__size { flex: none; color: var(--vr-muted); }
.cl-upload__bar { flex: 0 0 90px; height: 6px; border-radius: 999px; background: var(--vr-ghost-b); overflow: hidden; }
.cl-upload__bar > span { display: block; height: 100%; width: 0; border-radius: 999px; background: var(--vr-accent); transition: width .2s; }
.cl-upload__item.is-uploaded .cl-upload__bar { display: none; }
.cl-upload__item.is-uploaded > svg { color: var(--vr-good); }
.cl-upload__item.is-error { background: var(--vr-bad-soft); border-color: transparent; }
.cl-upload__item.is-error .cl-upload__bar { display: none; }
.cl-upload__msg { flex: none; font-size: 12px; font-weight: 700; color: var(--vr-bad); }
.cl-upload__msg:empty { display: none; }
.cl-upload__remove {
  flex: none; width: 34px; height: 34px; border: 0; border-radius: 10px; background: transparent; color: var(--vr-muted);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.cl-upload__remove:hover { background: var(--vr-bad-soft); color: var(--vr-bad); }
.cl-upload__pick {
  position: relative; display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 64px; box-sizing: border-box;
  padding: 12px 16px; border-radius: 14px; border: 1.5px dashed var(--vr-line-2); background: var(--vr-card);
  color: var(--vr-ink-2); font-size: 13px; font-weight: 700; cursor: pointer; text-align: center;
}
.cl-upload__pick:hover, .cl-upload__pick:focus-within { border-color: var(--vr-accent); background: var(--vr-accent-soft); color: var(--vr-accent-ink); }
.cl-upload__pick small { font-weight: 500; color: var(--vr-muted); }
.cl-upload__pick input[type="file"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.cl-upload__pick[hidden] { display: none; }

/* ---------- Book list ---------- */
.cl-search { position: relative; }
.cl-search svg { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--vr-muted); pointer-events: none; }
.cl-search .vr-input { padding-left: 46px; border-radius: 999px; }
.cl-subject { display: flex; flex-direction: column; gap: 12px; }
.cl-subject[hidden] { display: none; }
.cl-subject__head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px; }
.cl-books { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.cl-book { display: flex; flex-direction: column; min-width: 0; border-radius: var(--vr-r-2); background: var(--vr-card); box-shadow: var(--vr-shadow); overflow: hidden; }
.cl-book__cover { display: flex; align-items: center; justify-content: center; aspect-ratio: 3 / 4; padding: 14px; background: var(--vr-card-2); }
.cl-book__cover img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; border-radius: 4px; box-shadow: 0 6px 16px rgba(0, 0, 0, .14); }
.cl-book__cover svg { color: var(--vr-muted); }
.cl-book__body { flex: 1; display: flex; flex-direction: column; gap: 6px; padding: 12px 14px 4px; }
.cl-book__title { margin: 0; font-size: 14px; font-weight: 800; line-height: 1.35; }
.cl-book__title a { color: var(--vr-ink); text-decoration: none; }
.cl-book__title a:hover { color: var(--vr-accent-ink); }
.cl-book__author { margin: 0; font-size: 12px; color: var(--vr-muted); }
.cl-book__author strong { color: var(--vr-ink-2); }
.cl-book__foot { padding: 10px 14px 14px; display: flex; flex-direction: column; gap: 8px; }
.cl-book__foot .vr-btn { width: 100%; }
.cl-book-detail { display: flex; flex-direction: row; flex-wrap: wrap; gap: 28px; align-items: flex-start; }
.cl-book-detail__cover { flex: 0 0 240px; max-width: 100%; box-sizing: border-box; padding: 18px; border-radius: 16px; background: var(--vr-card-2); display: flex; justify-content: center; }
.cl-book-detail__cover img { width: 100%; height: auto; border-radius: 6px; box-shadow: 0 10px 24px rgba(0, 0, 0, .16); }
.cl-book-detail__body { flex: 1 1 320px; min-width: 0; display: flex; flex-direction: column; gap: 14px; }

@media (max-width: 720px) {
  .cl-editor { padding: 18px; }
  .cl-detail__title { font-size: 22px; }
  .cl-detail__sub { font-size: 16px; }
  .cl-tiles { grid-template-columns: 1fr; }
  .cl-books { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .cl-book__body { padding: 10px 10px 2px; }
  .cl-book__foot { padding: 8px 10px 10px; }
  .cl-upload__bar { flex-basis: 54px; }
  .cl-upload__size { display: none; }
}

/* Rich-text content from TinyMCE: tables were styled by Bootstrap's .table-bordered before */
.cl-stream .vr-prose table, .cl-detail .vr-prose table, .vr-post .vr-prose table { border-collapse: collapse; margin: 8px 0; }
.cl-stream .vr-prose td, .cl-stream .vr-prose th,
.cl-detail .vr-prose td, .cl-detail .vr-prose th,
.vr-post .vr-prose td, .vr-post .vr-prose th { border: 1px solid var(--vr-line-2); padding: 6px 10px; vertical-align: top; min-width: 2em; }
.vr-post .vr-prose th, .cl-detail .vr-prose th { background: var(--vr-card-2); }

/* File chips (vr-core .vr-files / .vr-file): a long file name widened the page on phones (sideways scroll) because the
   list item kept its full one-line text width and the chip's padding came on top of max-width:100%. Let the item
   shrink and keep the chip inside it; the name is ellipsised by vr-core. */
.vr-files > li { min-width: 0; max-width: 100%; }
.vr-files .vr-file { box-sizing: border-box; }
