/* Courses page (index.html). Uses the colour/shape tokens from styles.css. */

.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.cat-head { background: var(--surface); border-bottom: 1px solid var(--border); }
.cat-head-in { max-width: 1240px; margin: 0 auto; padding: 1.6rem 1.25rem 1.3rem; }
.cat-head h1 { margin: 0; font-size: 1.75rem; line-height: 1.2; letter-spacing: -0.01em; color: var(--primary-dark); }
.cat-sub { margin: 0.35rem 0 0; color: var(--text-muted); max-width: 60ch; }
.cat-progress { margin: 0.5rem 0 0; font-size: 0.85rem; color: var(--text-subtle); }
.cat-progress a { color: var(--primary); }

.cat-body { max-width: 1240px; margin: 0 auto; padding: 1.4rem 1.25rem 3rem; display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 1.75rem; align-items: start; }

/* ---------- filter panel ---------- */
.cat-filters { position: sticky; top: calc(var(--header-h) + 1rem); max-height: calc(100vh - var(--header-h) - 2rem); overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 0.4rem 1rem 1rem; }
.cat-filters-head { display: flex; align-items: center; justify-content: space-between; padding: 0.7rem 0 0.4rem; }
.cat-filters-head h2 { margin: 0 auto 0 0; font-size: 0.95rem; }
.cat-filters-head button { background: none; border: 0; color: var(--primary); font: inherit; font-size: 0.85rem; cursor: pointer; padding: 0.25rem 0; }
.cat-filters-head button:hover { text-decoration: underline; }
#cat-close-filters { display: none; font-size: 1.5rem; line-height: 1; color: var(--text-muted); padding: 0 0.3rem; }
.cat-fset { border: 0; border-top: 1px solid var(--border); margin: 0; padding: 0.8rem 0 0.4rem; min-width: 0; }
.cat-fset legend { padding: 0; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-subtle); float: left; width: 100%; margin-bottom: 0.4rem; }
.cat-fset legend + * { clear: both; }
.cat-opt { display: flex; align-items: center; gap: 0.55rem; padding: 0.32rem 0.1rem; font-size: 0.9rem; cursor: pointer; border-radius: var(--r-sm); }
.cat-opt:hover { background: var(--primary-50); }
.cat-opt input { accent-color: var(--primary); width: 1rem; height: 1rem; margin: 0; flex: none; }
.cat-opt-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.cat-opt-n { font-size: 0.78rem; color: var(--text-subtle); font-variant-numeric: tabular-nums; }
.cat-opt.is-empty { opacity: 0.45; cursor: default; }
.cat-opt.is-empty:hover { background: none; }
.cat-sheet-foot { display: none; }

/* ---------- toolbar ---------- */
.cat-bar { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; }
.cat-search { position: relative; flex: 1 1 260px; min-width: 0; }
.cat-search svg { position: absolute; left: 0.8rem; top: 50%; transform: translateY(-50%); width: 1rem; height: 1rem; color: var(--text-subtle); pointer-events: none; }
.cat-search input { width: 100%; height: 2.6rem; padding: 0 2.2rem 0 2.4rem; border: 1px solid var(--border-strong); border-radius: var(--r-md); background: var(--surface); font: inherit; color: var(--text); }
.cat-search input:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: var(--primary); }
.cat-search input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.cat-search button { position: absolute; right: 0.3rem; top: 50%; transform: translateY(-50%); width: 2rem; height: 2rem; border: 0; background: none; color: var(--text-subtle); font-size: 1.3rem; line-height: 1; cursor: pointer; border-radius: 50%; }
.cat-search button:hover { background: var(--primary-50); color: var(--primary-dark); }
.cat-select { display: flex; align-items: center; gap: 0.45rem; font-size: 0.85rem; color: var(--text-muted); }
.cat-cap { white-space: nowrap; }
.cat-select select { height: 2.6rem; padding: 0 0.7rem; border: 1px solid var(--border-strong); border-radius: var(--r-md); background: var(--surface); font: inherit; font-size: 0.9rem; color: var(--text); max-width: 100%; }
.cat-select select:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
#cat-open-filters { display: none; height: 2.6rem; align-items: center; gap: 0.45rem; padding: 0 0.9rem; border: 1px solid var(--border-strong); border-radius: var(--r-md); background: var(--surface); font: inherit; font-weight: 600; color: var(--text); cursor: pointer; }
#cat-open-filters.has-n { border-color: var(--primary); color: var(--primary); }
.cat-filter-n { min-width: 1.25rem; height: 1.25rem; padding: 0 0.3rem; border-radius: 99px; background: var(--primary); color: #fff; font-size: 0.75rem; display: inline-flex; align-items: center; justify-content: center; }
.cat-filter-n:empty { display: none; }

.cat-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 0.45rem; margin: 0.9rem 0 1.1rem; min-height: 1.9rem; }
.cat-count { font-size: 0.9rem; font-weight: 600; color: var(--text); margin-right: 0.3rem; }
.cat-chip { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.25rem 0.55rem 0.25rem 0.7rem; border: 1px solid var(--primary-100); background: var(--primary-50); color: var(--primary-dark); border-radius: 99px; font: inherit; font-size: 0.82rem; cursor: pointer; }
.cat-chip:hover { border-color: var(--primary); }
.cat-clear { background: none; border: 0; color: var(--primary); font: inherit; font-size: 0.85rem; cursor: pointer; padding: 0.25rem 0.3rem; }
.cat-clear:hover { text-decoration: underline; }

/* ---------- results ---------- */
.cat-group + .cat-group { margin-top: 2rem; }
.cat-group-title { display: flex; align-items: baseline; gap: 0.5rem; margin: 0 0 0.8rem; padding-bottom: 0.45rem; border-bottom: 1px solid var(--border); font-size: 1.05rem; color: var(--primary-dark); }
.cat-group-title span { font-size: 0.8rem; font-weight: 500; color: var(--text-subtle); }
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 1rem; }

.cat-card { position: relative; display: flex; flex-direction: column; gap: 0.55rem; padding: 1.05rem 1.1rem 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); transition: border-color 0.15s, box-shadow 0.15s; }
.cat-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.cat-card:focus-within { border-color: var(--primary); }
.cat-card-top { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; font-size: 0.75rem; }
.cat-code { font-weight: 700; letter-spacing: 0.04em; color: var(--primary); }
.cat-kind { color: var(--text-subtle); }
.cat-title { margin: 0; font-size: 1.08rem; line-height: 1.3; }
.cat-title a { color: var(--primary-dark); text-decoration: none; }
.cat-title a::after { content: ''; position: absolute; inset: 0; border-radius: var(--r-lg); }   /* whole card is the link */
.cat-title a:focus-visible { outline: none; }
.cat-title a:focus-visible::after { outline: 2px solid var(--primary); outline-offset: 2px; }
.cat-desc { margin: 0; color: var(--text-muted); font-size: 0.88rem; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.cat-tags { display: flex; flex-wrap: wrap; gap: 0.35rem; position: relative; z-index: 1; }   /* above the card link */
.cat-tag { padding: 0.12rem 0.55rem; border-radius: 99px; font: inherit; font-size: 0.75rem; line-height: 1.5; cursor: pointer; border: 1px solid transparent; }
.cat-tag-product { background: var(--primary-50); color: var(--primary-dark); border-color: var(--primary-100); }
.cat-tag-subject { background: transparent; color: var(--text-muted); border-color: var(--border-strong); }
.cat-tag:hover { border-color: var(--primary); }
.cat-tag.is-on { background: var(--primary); color: #fff; border-color: var(--primary); }
.cat-foot { margin-top: auto; padding-top: 0.6rem; display: flex; flex-direction: column; gap: 0.5rem; }
.cat-meta { display: flex; flex-wrap: wrap; gap: 0.2rem 0.85rem; font-size: 0.8rem; color: var(--text-muted); }
.cat-prog { display: flex; align-items: center; gap: 0.6rem; font-size: 0.78rem; color: var(--text-muted); }
.cat-prog-bar { flex: 1; height: 5px; border-radius: 99px; background: var(--primary-100); overflow: hidden; }
.cat-prog-bar span { display: block; height: 100%; background: var(--primary); border-radius: inherit; }
.cat-go { font-size: 0.88rem; font-weight: 600; color: var(--primary); }
.cat-card:hover .cat-go { text-decoration: underline; }

.cat-empty { padding: 3rem 1rem; text-align: center; color: var(--text-muted); background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--r-lg); }
.cat-empty p { margin: 0 0 0.5rem; }
.cat-empty .btn { margin-top: 0.6rem; }

/* ---------- tablet / mobile: filters become a bottom sheet ---------- */
@media (max-width: 900px) {
  .cat-head-in { padding: 1.2rem 1rem 1rem; }
  .cat-head h1 { font-size: 1.5rem; }
  .cat-body { grid-template-columns: minmax(0, 1fr); padding: 1rem 1rem 2.5rem; gap: 0; }
  #cat-open-filters { display: inline-flex; }
  .cat-search { flex-basis: 100%; }
  .cat-select { flex: 1 1 0; min-width: 0; flex-direction: column; align-items: stretch; gap: 0.15rem; }
  .cat-cap { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-subtle); }
  .cat-select select { width: 100%; min-width: 0; text-overflow: ellipsis; }
  #cat-open-filters { align-self: flex-end; }
  #cat-open-filters { flex: 1 1 0; justify-content: center; }

  .cat-filters { position: fixed; z-index: 70; left: 0; right: 0; bottom: 0; top: auto; max-height: 85vh; border-radius: var(--r-xl) var(--r-xl) 0 0; border-width: 1px 0 0; padding: 0 1.1rem 0; transform: translateY(105%); visibility: hidden; transition: transform 0.22s ease, visibility 0s linear 0.22s; box-shadow: var(--shadow-lg); }
  .cat-sheet-open .cat-filters { transform: none; visibility: visible; transition: transform 0.22s ease; }
  .cat-filters-head { position: sticky; top: 0; background: var(--surface); z-index: 1; padding-top: 1rem; }
  #cat-close-filters { display: block; }
  .cat-opt { padding: 0.6rem 0.1rem; font-size: 0.95rem; }
  .cat-sheet-foot { display: block; position: sticky; bottom: 0; background: var(--surface); padding: 0.8rem 0 calc(0.8rem + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); margin-top: 0.6rem; }
  .cat-sheet-foot .btn { width: 100%; justify-content: center; }
  .cat-backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(20, 16, 46, 0.45); opacity: 0; pointer-events: none; transition: opacity 0.2s; }
  .cat-sheet-open .cat-backdrop { opacity: 1; pointer-events: auto; }
  .cat-sheet-open { overflow: hidden; }
  .cat-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (min-width: 901px) { .cat-backdrop { display: none; } }

@media (prefers-reduced-motion: reduce) {
  .cat-filters, .cat-backdrop, .cat-card { transition: none; }
}
