/* ============================================================
   LEARNSPACE — library.css
   Single continuous library surface, not a wizard.
   - Hero: light, on-brand, matches the rest of the site.
   - Curriculum: a slim chip strip that collapses to one pill
     once a specific curriculum is chosen.
   - Format tabs + subject search share a single row.
   - Papers are filed in year folders — the page's one
     signature device, because that's how a real archive works.
   ============================================================ */

/* ── LIBRARY HERO ───────────────────────────────────────── */
.lib-hero {
  padding: 56px 0 44px;
  border-bottom: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}
.lib-hero::before {
  content: '';
  position: absolute; inset: 0;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 56px 56px;
  opacity: .35;
  pointer-events: none;
}
.lib-hero .container { position: relative; z-index: 1; }
.lib-hero__inner { max-width: 620px; }

.lib-hero__eyebrow {
  display: inline-flex; align-items: center; gap: 10px;
  font-size: .7rem; font-weight: 700; letter-spacing: .16em;
  text-transform: uppercase; color: var(--accent);
  margin-bottom: 16px;
}
.lib-hero__eyebrow::before {
  content: ''; width: 24px; height: 1px;
  background: var(--accent);
}

.lib-hero__title {
  margin-bottom: 12px;
  font-size: clamp(1.9rem, 4vw, 2.6rem);
}
.lib-hero__subtitle {
  font-size: .96rem; line-height: 1.7;
  color: var(--ink-2);
  max-width: 480px;
  margin-bottom: 24px;
}

.lib-hero__search-wrap { position: relative; max-width: 440px; margin-bottom: 26px; }
.lib-hero__search-icon {
  position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: .82rem; pointer-events: none;
}
.lib-hero__search {
  width: 100%;
  padding: 12px 16px 12px 42px;
  border-radius: var(--r-sm);
  border: 1.5px solid var(--border);
  background: var(--white);
  color: var(--ink);
  font-size: .88rem;
  font-family: 'Inter', sans-serif;
  transition: var(--ease);
}
.lib-hero__search::placeholder { color: #bbb; }
.lib-hero__search:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(17,17,17,.05);
}

.lib-hero__stats { display: flex; gap: 32px; flex-wrap: wrap; }
.lib-stat { display: flex; flex-direction: column; gap: 2px; }
.lib-stat__num {
  font-family: 'Fraunces', serif; font-weight: 900;
  font-size: 1.5rem; color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.lib-stat__label {
  font-size: .69rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); font-weight: 600;
}

/* ── CURRICULUM STRIP ───────────────────────────────────── */
.curric-strip {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 0;
}
.curric-strip__row { display: flex; align-items: center; }

/* slim horizontal chip row — not a grid/table */
.curric-bar {
  display: flex; flex-wrap: wrap; gap: 8px;
}
.curric-chip {
  padding: 9px 18px;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: var(--white);
  color: var(--ink-2);
  font-size: .82rem; font-weight: 600;
  cursor: pointer; transition: var(--ease);
  white-space: nowrap;
}
.curric-chip:hover { border-color: var(--ink); color: var(--ink); }
.curric-chip.active { background: var(--ink); border-color: var(--ink); color: var(--white); }

/* the collapsed state once a curriculum is chosen */
.curric-pill {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 9px 16px 9px 18px;
  border-radius: 999px;
  border: none;
  background: var(--accent);
  color: var(--white);
  font-size: .83rem; font-weight: 600;
  cursor: pointer; transition: var(--ease);
}
.curric-pill:hover { background: var(--accent-md); }
.curric-pill i:first-child { font-size: .8rem; opacity: .85; }
.curric-pill__clear {
  font-size: .68rem; opacity: .65; margin-left: 2px;
}

/* ── BROWSE BAR (format tabs + subject search) ──────────── */
.browse-bar {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 18px 0;
  position: sticky;
  top: var(--nav-h);
  z-index: 50;
}
.browse-bar__row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  margin-bottom: 12px;
}

.lib-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.lib-tab {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px;
  border-radius: var(--r);
  border: 1.5px solid var(--border);
  background: var(--white);
  color: var(--ink-2);
  font-size: .84rem; font-weight: 600;
  cursor: pointer; transition: var(--ease);
}
.lib-tab i { font-size: .8rem; color: var(--muted); transition: var(--ease); }
.lib-tab:hover { border-color: var(--ink); color: var(--ink); }
.lib-tab.active { background: var(--ink); border-color: var(--ink); color: var(--white); }
.lib-tab.active i { color: rgba(255,255,255,.7); }

.subject-search-wrap { position: relative; width: 240px; flex-shrink: 0; }
.subject-search-icon {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: .76rem; pointer-events: none;
}
.subject-search {
  width: 100%;
  padding: 9px 14px 9px 36px;
  border-radius: var(--r-sm);
  border: 1.5px solid var(--border);
  background: var(--white);
  font-size: .82rem; font-family: 'Inter', sans-serif;
  transition: var(--ease);
}
.subject-search:focus { outline: none; border-color: var(--ink); }
.subject-search::placeholder { color: #bbb; }

.subject-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.subject-chip {
  padding: 7px 15px;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: var(--white);
  color: var(--ink-2);
  font-size: .79rem; font-weight: 500;
  cursor: pointer; transition: var(--ease);
}
.subject-chip:hover { border-color: var(--ink); color: var(--ink); }
.subject-chip.active { background: var(--ink); border-color: var(--ink); color: var(--white); }
.subject-chips-empty { font-size: .8rem; color: var(--muted); padding: 6px 0; }

/* ── RESULTS SECTION ────────────────────────────────────── */
.lib-results { padding: 28px 0 64px; }

.lib-result-bar {
  margin-bottom: 16px;
  font-size: .82rem; color: var(--muted); font-weight: 500;
}

/* ── LOADING / EMPTY ────────────────────────────────────── */
.lib-loading { text-align: center; padding: 64px 24px; }
.lib-loading__spinner {
  width: 28px; height: 28px; margin: 0 auto 14px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  animation: spin .7s linear infinite;
}
.lib-loading p { font-size: .84rem; color: var(--muted); }

.lib-empty {
  text-align: center; padding: 64px 24px;
  background: var(--surface); border-radius: var(--r);
  border: 1px dashed var(--border);
}
.lib-empty__icon {
  font-size: 1.4rem; color: var(--muted);
  width: 52px; height: 52px; margin: 0 auto 16px;
  border-radius: 50%; background: var(--white);
  display: flex; align-items: center; justify-content: center;
}
.lib-empty h4 { margin-bottom: 6px; }
.lib-empty p { font-size: .84rem; color: var(--muted); margin-bottom: 4px; }

/* ── YEAR FOLDERS (signature element) ───────────────────── */
/* Past papers filed the way a real archive shelves them:
   one folder per year, most recent open by default. */
#papers-container { display: flex; flex-direction: column; gap: 10px; }

.year-folder {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  transition: border-color .18s;
}
.year-folder.open { border-color: #d2d2d2; }

.year-folder__head {
  width: 100%;
  display: flex; align-items: center; gap: 12px;
  padding: 15px 18px;
  background: none; border: none; cursor: pointer;
  text-align: left; transition: var(--ease);
}
.year-folder__head:hover { background: var(--surface); }

.year-folder__icon {
  font-size: .92rem; color: var(--muted); width: 18px; text-align: center;
}
.year-folder.open .year-folder__icon { color: var(--accent); }

.year-folder__title {
  font-family: 'Fraunces', serif; font-weight: 700;
  font-size: 1.05rem; color: var(--ink);
}
.year-folder__count {
  margin-left: auto;
  font-size: .74rem; font-weight: 600; color: var(--muted);
  background: var(--surface); padding: 3px 11px; border-radius: 999px;
}
.year-folder.open .year-folder__count { background: var(--accent-lt); color: var(--accent); }

.year-folder__chevron {
  font-size: .7rem; color: var(--muted);
  transition: transform .2s ease;
}
.year-folder.open .year-folder__chevron { transform: rotate(180deg); }

.year-folder__body {
  max-height: 0;
  overflow: hidden;
  transition: max-height .3s ease;
}
.year-folder.open .year-folder__body {
  max-height: 4000px;
}
.year-folder__body .papers-row {
  padding: 2px 18px 18px;
}

/* ── PAPERS ROW / CARD ──────────────────────────────────── */
.papers-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}

.paper-card {
  display: flex; gap: 14px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--white);
  transition: var(--ease);
}
.paper-card:hover { border-color: #ccc; box-shadow: var(--sh); }

.paper-card__icon {
  width: 36px; height: 36px; flex-shrink: 0;
  border-radius: var(--r-sm);
  background: var(--err-bg); color: var(--err);
  display: flex; align-items: center; justify-content: center;
  font-size: .95rem;
}
.paper-card__body { flex: 1; min-width: 0; }
.paper-card__title {
  font-size: .86rem; font-weight: 700; color: var(--ink);
  margin-bottom: 4px; line-height: 1.35;
}
.paper-card__meta {
  display: flex; flex-wrap: wrap; gap: 6px;
  font-size: .71rem; color: var(--muted); margin-bottom: 4px;
}
.paper-card__meta span:not(:last-child)::after { content: '·'; margin-left: 6px; color: var(--border); }
.paper-card__desc { font-size: .75rem; color: var(--muted); line-height: 1.5; margin-top: 4px; }
.paper-card__tags { margin-top: 8px; }
.paper-tag {
  display: inline-flex; align-items: center;
  font-size: .67rem; font-weight: 600;
  padding: 3px 9px; border-radius: 999px;
}
.paper-tag--ans { background: var(--ok-bg); color: var(--ok); }

.paper-card__actions {
  display: flex; flex-direction: column; gap: 6px; flex-shrink: 0;
}
.paper-card__actions .btn { padding: 7px 11px; }

/* ── NOTES — TOPIC GROUPS ───────────────────────────────── */
#notes-container { display: flex; flex-direction: column; gap: 32px; }
.topic-group__title {
  font-size: 1rem; margin-bottom: 14px;
  padding-bottom: 9px; border-bottom: 1px solid var(--border);
}

.note-card {
  display: flex; gap: 14px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--white);
  transition: var(--ease);
}
.note-card:hover { border-color: #ccc; box-shadow: var(--sh); }

.note-card__icon {
  width: 36px; height: 36px; flex-shrink: 0;
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: .66rem; font-weight: 800; letter-spacing: .02em;
}
.note-ext--pdf { background: var(--err-bg);  color: var(--err); }
.note-ext--ppt { background: var(--warn-bg); color: var(--warn); }
.note-ext--doc { background: var(--info-bg); color: var(--info); }

.note-card__body { flex: 1; min-width: 0; }
.note-card__title { font-size: .86rem; font-weight: 700; color: var(--ink); margin-bottom: 4px; }
.note-card__meta { font-size: .71rem; color: var(--muted); margin-bottom: 4px; }
.note-card__desc { font-size: .75rem; color: var(--muted); line-height: 1.5; }
.note-card__actions { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }
.note-card__actions .btn { padding: 7px 11px; }

/* ── VIDEOS — GRID ──────────────────────────────────────── */
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 18px; }

.vid-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  transition: var(--ease);
}
.vid-card:hover { box-shadow: var(--sh-md); transform: translateY(-2px); border-color: #ccc; }

.vid-card__thumb {
  position: relative; aspect-ratio: 16/9;
  background: var(--ink); cursor: pointer; overflow: hidden;
}
.vid-card__thumb img { width: 100%; height: 100%; object-fit: cover; }
.video-thumb-placeholder {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,.3); font-size: 1.5rem;
}
.vid-card__play {
  position: absolute; inset: 0; margin: auto; width: 44px; height: 44px;
  background: rgba(255,255,255,.92); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink); font-size: .88rem;
  transition: var(--ease);
}
.vid-card:hover .vid-card__play { background: var(--white); transform: scale(1.06); }
.vid-card__duration {
  position: absolute; bottom: 8px; right: 8px;
  background: rgba(0,0,0,.75); color: var(--white);
  font-size: .67rem; font-weight: 600; padding: 2px 7px; border-radius: 4px;
}

.vid-card__body { padding: 13px 15px; }
.vid-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .65rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  padding: 3px 9px; border-radius: 999px; margin-bottom: 8px;
}
.vid-badge--rec { background: var(--err-bg); color: var(--err); }
.vid-badge--rec i { font-size: .5rem; }
.vid-badge--yt  { background: var(--err-bg); color: var(--err); }

.vid-card__title { font-size: .86rem; font-weight: 700; color: var(--ink); margin-bottom: 6px; line-height: 1.35; }
.vid-card__meta { display: flex; flex-direction: column; gap: 3px; font-size: .72rem; color: var(--muted); }
.vid-card__meta span { display: flex; align-items: center; gap: 6px; }
.vid-card__meta i { font-size: .67rem; width: 12px; }

/* ── MODAL — PDF / VIDEO specifics ──────────────────────── */
.pdf-modal-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 18px; padding-right: 40px;
}
.pdf-modal-sub { font-size: .8rem; color: var(--muted); margin-top: 4px; }
#pdf-viewer-wrap { width: 100%; height: 70vh; border-radius: var(--r-sm); overflow: hidden; background: var(--surface); }
#pdf-iframe { width: 100%; height: 100%; border: none; }

.video-modal-meta { padding-top: 16px; }
.video-modal-title { font-family: 'Fraunces', serif; font-size: 1.1rem; font-weight: 700; margin-bottom: 8px; }
.video-modal-sub { display: flex; flex-wrap: wrap; gap: 8px; font-size: .78rem; color: var(--muted); margin-bottom: 8px; }
.video-modal-sub span:not(:last-child)::after { content: '·'; margin-left: 8px; color: var(--border); }
.video-modal-desc { font-size: .85rem; color: var(--ink-2); line-height: 1.6; }

/* ── RESPONSIVE ─────────────────────────────────────────── */
@media (max-width: 900px) {
  .papers-row { grid-template-columns: 1fr; }
  .lib-grid   { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
  .browse-bar { position: static; }
}
@media (max-width: 640px) {
  .lib-hero { padding: 44px 0 32px; }
  .lib-hero__stats { gap: 20px; }
  .lib-tabs { width: 100%; }
  .lib-tab { flex: 1; justify-content: center; }
  .browse-bar__row { flex-direction: column; align-items: stretch; }
  .subject-search-wrap { width: 100%; }
  .pdf-modal-header { padding-right: 0; flex-direction: column; }
  .paper-card, .note-card { flex-direction: column; }
  .paper-card__actions, .note-card__actions { flex-direction: row; }
}

@media (prefers-reduced-motion: reduce) {
  .year-folder__body, .year-folder__chevron, .year-folder__icon { transition: none; }
}
