/* ================================================================
   DAA Course Hub — dark course index
   Self-contained: this page does not load reveal.js.
   ================================================================ */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #fafafa;
  --bg-elevated: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f4f5f7;
  --border: #d0d7de;
  --border-hover: #a0aec0;
  --text: #111111;
  --text-muted: #555555;
  --text-dim: #777777;
  --accent: #58a6ff;
  --accent-hover: #79b8ff;
  --accent-soft: rgba(88, 166, 255, 0.1);
  --violet: #a371f7;
  --green: #3fb950;
  --green-soft: rgba(63, 185, 80, 0.12);
  --amber: #d29922;
  --amber-soft: rgba(210, 153, 34, 0.12);
  --radius: 14px;
  --radius-lg: 20px;
  --shadow: 0 18px 36px -18px rgba(15, 23, 42, 0.18);
  --ease: cubic-bezier(0.23, 1, 0.32, 1);
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: #fafafa;
}

.wrap {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

a {
  color: var(--accent);
  text-decoration: none;
}

/* ---------------------------------------------------------------
   Hero
   --------------------------------------------------------------- */
.hero {
  padding: 3rem 0 2.5rem;
  border-bottom: 1px solid var(--border);
}

.hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 2.2rem;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  transition: color 0.2s ease;
}

.back-link:hover {
  color: var(--accent);
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.13em;
  text-transform: uppercase;
  padding: 0.5rem 0.95rem;
  border: 1px solid rgba(88, 166, 255, 0.25);
  border-radius: 999px;
  background: var(--accent-soft);
}

.hero-badge .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 10px var(--green);
}

.hero h1 {
  font-size: clamp(2.4rem, 6vw, 4.1rem);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.04;
  color: #111111;
  max-width: 18ch;
}

.hero .lede {
  margin-top: 1.1rem;
  max-width: 62ch;
  font-size: 1.02rem;
  color: var(--text-muted);
}

.hero .lede strong {
  color: var(--text);
  font-weight: 600;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  margin-top: 2.4rem;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.stat {
  background: var(--bg-elevated);
  padding: 1.1rem 1.2rem;
}

.stat strong {
  display: block;
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.stat span {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
}

/* ---------------------------------------------------------------
   Toolbar
   --------------------------------------------------------------- */
.toolbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1.1rem 0;
  background: rgba(250, 250, 250, 0.9);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.search-box {
  position: relative;
  flex: 1 1 260px;
  max-width: 380px;
}

.search-box svg {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-dim);
  pointer-events: none;
}

.search-box input {
  width: 100%;
  padding: 0.65rem 0.9rem 0.65rem 2.4rem;
  font-family: inherit;
  font-size: 0.86rem;
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-box input::placeholder {
  color: var(--text-dim);
}

.search-box input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-box kbd {
  position: absolute;
  right: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  font-family: inherit;
  font-size: 0.65rem;
  color: var(--text-dim);
  padding: 0.1rem 0.35rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--bg-elevated);
}

.chips {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.chip {
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0.42rem 0.8rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.chip:hover {
  color: var(--text);
  border-color: var(--border-hover);
}

.chip.is-active {
  color: var(--accent);
  border-color: rgba(88, 166, 255, 0.45);
  background: var(--accent-soft);
}

/* ---------------------------------------------------------------
   Unit grid
   --------------------------------------------------------------- */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin: 2.6rem 0 1.1rem;
}

.section-head h2 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.section-head p {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.unit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 1.1rem;
}

.unit-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  padding: 1.35rem 1.35rem 1.2rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  color: inherit;
  transition: transform 0.35s var(--ease), border-color 0.25s ease, background 0.25s ease,
    box-shadow 0.35s var(--ease);
}

a.unit-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-hover);
  background: var(--bg-card-hover);
  box-shadow: var(--shadow);
}

.unit-card.is-planned {
  cursor: default;
}

.unit-card.is-planned:hover {
  border-color: var(--border);
  background: var(--bg-card);
  transform: none;
  box-shadow: none;
}

.unit-card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
  background: transparent;
}

a.unit-card:hover::after {
  opacity: 1;
}

.unit-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.unit-no {
  font-family: 'Fira Code', ui-monospace, monospace;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--accent);
  padding: 0.2rem 0.55rem;
  border: 1px solid rgba(88, 166, 255, 0.22);
  border-radius: 6px;
  background: var(--accent-soft);
}

.pill {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 0.2rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  white-space: nowrap;
}

.unit-card h3 {
  font-size: 1.06rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.unit-card .topics {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  font-size: 0.79rem;
  color: var(--text-muted);
}

.unit-card .topics li {
  position: relative;
  padding-left: 0.95rem;
  line-height: 1.45;
}

.unit-card .topics li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.55em;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--text-dim);
}

.unit-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: auto;
  padding-top: 0.55rem;
  border-top: 1px solid var(--border);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-dim);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-size: 0.65rem;
}

.status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status.planned {
  color: var(--amber);
}

.status.ready {
  color: var(--green);
}

.open-deck {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--accent);
  transition: gap 0.2s ease;
}

a.unit-card:hover .open-deck {
  gap: 0.5rem;
}

.is-planned .open-deck {
  color: var(--text-dim);
}

/* Category tints */
.unit-card[data-category="foundations"] .unit-no {
  color: #79b8ff;
}

.unit-card[data-category="structures"] .unit-no {
  color: #56d364;
  border-color: rgba(63, 185, 80, 0.25);
  background: rgba(63, 185, 80, 0.1);
}

.unit-card[data-category="paradigms"] .unit-no {
  color: #b794f6;
  border-color: rgba(163, 113, 247, 0.25);
  background: rgba(163, 113, 247, 0.1);
}

.unit-card[data-category="specialised"] .unit-no {
  color: #39c5cf;
  border-color: rgba(57, 197, 207, 0.25);
  background: rgba(57, 197, 207, 0.1);
}

.unit-card[data-category="theory"] .unit-no {
  color: #e3b341;
  border-color: rgba(210, 153, 34, 0.25);
  background: rgba(210, 153, 34, 0.1);
}

/* Empty state */
.empty {
  display: none;
  padding: 3rem 1rem;
  text-align: center;
  color: var(--text-muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.empty strong {
  display: block;
  color: var(--text);
  margin-bottom: 0.25rem;
}

body.is-filtered .empty.is-visible {
  display: block;
}

/* ---------------------------------------------------------------
   Syllabus table
   --------------------------------------------------------------- */
.panel {
  margin-top: 3rem;
  padding: 1.6rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.panel h2 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 0.3rem;
}

.panel > p {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 1.1rem;
}

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

table.syllabus {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  min-width: 720px;
}

table.syllabus th,
table.syllabus td {
  padding: 0.65rem 0.9rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}

table.syllabus thead th {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  background: var(--bg-card);
  white-space: nowrap;
}

table.syllabus tbody tr:last-child td {
  border-bottom: none;
}

table.syllabus tbody tr:hover {
  background: rgba(13, 110, 253, 0.05);
}

table.syllabus td.no {
  font-family: 'Fira Code', ui-monospace, monospace;
  color: var(--accent);
  white-space: nowrap;
}

table.syllabus td.hrs {
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  white-space: nowrap;
}

table.syllabus td.title {
  font-weight: 600;
  white-space: nowrap;
}

table.syllabus td.desc {
  color: var(--text-muted);
}

/* ---------------------------------------------------------------
   Books
   --------------------------------------------------------------- */
.books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
  margin-top: 0.9rem;
}

.book {
  display: flex;
  gap: 0.9rem;
  padding: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.book .spine {
  flex: 0 0 10px;
  border-radius: 4px;
  background: var(--accent);
  opacity: 0.8;
}

.book.ref .spine {
  background: var(--green);
}

.book h4 {
  font-size: 0.86rem;
  font-weight: 650;
  line-height: 1.35;
  margin-bottom: 0.2rem;
}

.book p {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.book .role {
  display: inline-block;
  margin-top: 0.4rem;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}

.book.ref .role {
  color: var(--green);
}

/* ---------------------------------------------------------------
   Notes + footer
   --------------------------------------------------------------- */
.usage {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-top: 0.9rem;
}

.usage-item {
  padding: 0.95rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.usage-item h4 {
  font-size: 0.8rem;
  font-weight: 650;
  margin-bottom: 0.2rem;
}

.usage-item p {
  font-size: 0.74rem;
  color: var(--text-muted);
}

kbd {
  font-family: 'Fira Code', ui-monospace, monospace;
  font-size: 0.7em;
  padding: 0.1em 0.4em;
  border: 1px solid var(--border-hover);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--bg-card);
  color: var(--text);
}

footer.site {
  margin-top: 3.5rem;
  padding: 2rem 0 3rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.75rem;
  color: var(--text-dim);
}

footer.site .brand {
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 2rem;
  transform: translate(-50%, 1rem);
  z-index: 50;
  padding: 0.65rem 1.1rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--border-hover);
  border-radius: 10px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s var(--ease);
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------------------------------------------------------------
   Responsive
   --------------------------------------------------------------- */
@media (max-width: 760px) {
  .hero {
    padding-top: 2rem;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .unit-grid {
    grid-template-columns: 1fr;
  }

  .toolbar {
    position: static;
  }

  .search-box {
    max-width: none;
  }

  .search-box kbd {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }

  html {
    scroll-behavior: auto;
  }
}

@media print {
  body::before,
  .toolbar,
  .toast,
  footer.site {
    display: none;
  }

  body {
    background: #fff;
    color: #111;
  }

  .unit-card,
  .panel,
  .book,
  .usage-item {
    break-inside: avoid;
    border-color: #ddd;
    background: #fff;
  }

  .hero h1 {
    -webkit-text-fill-color: #111;
    color: #111;
  }
}
