/* Home page styles - both layouts ("by grade" and "by subject") */

/* ======================= "By grade" layout ======================= */

.grade-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 40px;
  align-items: start;
}

.grade-rail {
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: sticky;
  top: 24px;
}
.grade-rail .eyebrow { padding: 0 0 8px 4px; }
.grade-buttons { display: flex; flex-direction: column; gap: 6px; }

.grade-btn {
  height: 56px;
  border: none;
  border-radius: 14px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: transparent;
  color: var(--ink);
}
.grade-btn:hover { background: var(--soft); }
.grade-btn.selected { background: var(--primary); color: var(--on-primary); }
.grade-btn.no-results { opacity: 0.5; }
.grade-btn .label { font-size: 18px; font-weight: 800; }
.grade-btn .count { font-size: 16px; font-weight: 700; opacity: 0.85; }

.grade-content { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.content-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.content-head h1 { margin: 0; font-size: 30px; font-weight: 800; }
.content-head .sub { font-size: 17px; font-weight: 700; color: var(--muted); }
.grade-content .topic-grid { --card-min: 250px; }

/* Small screens: grade list becomes a row of pills you can scroll sideways */
@media (max-width: 820px) {
  .grade-layout { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .grade-rail { position: static; }
  .grade-rail .eyebrow { display: none; }
  .grade-buttons { flex-direction: row; overflow-x: auto; gap: 8px; padding-bottom: 4px; }
  .grade-btn {
    flex: none; height: 46px; gap: 10px; border-radius: 23px;
    border: 1px solid var(--border); background: var(--surface);
  }
  .grade-btn.selected { border-color: var(--primary); }
  .content-head h1 { font-size: 24px; }
}


/* ======================= "By subject" layout ======================= */

.chips { display: flex; flex-wrap: wrap; gap: 10px; }

.chip {
  height: 44px;
  padding: 0 18px;
  border-radius: 22px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 800;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
}
.chip:hover { border-color: var(--hover-border); }
.chip.selected { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.chip .count { font-size: 14px; font-weight: 700; opacity: 0.75; }

.subject-sections { display: flex; flex-direction: column; gap: 32px; }
.subject-section { display: flex; flex-direction: column; gap: 16px; padding-top: 8px; }
.subject-section h2 { margin: 0; font-size: 26px; font-weight: 800; }
.subject-section .sub { font-size: 16px; font-weight: 700; color: var(--muted); }
.subject-section .topic-grid { --card-min: 230px; gap: 16px; }
.subject-section .card { padding: 16px; }
.subject-section .card-name { font-size: 18px; }

@media (max-width: 640px) {
  .chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
  .chip { flex: none; }
  .subject-section h2 { font-size: 22px; }
}


/* ======================= "All topics" layout (design 2c) ======================= */

/* Cards flow down 4 columns, like a newspaper. Each card keeps its own height,
   so short and long sub-topic lists pack together without gaps. */
.topic-columns {
  column-count: 4;
  column-gap: 18px;
}

.topic-card {
  break-inside: avoid;        /* never split a card between two columns */
  display: flex;
  flex-direction: column;
  margin: 0 0 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  transition: border-color .12s, box-shadow .12s;
}
.topic-card:hover { border-color: var(--hover-border); box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06); }

/* Top: name, "2 matching sub-topics", progress */
.topic-card-top { padding: 18px 18px 14px; display: flex; flex-direction: column; gap: 8px; }
.topic-card-name { font-size: 19px; font-weight: 800; line-height: 1.3; color: var(--ink); }
.topic-card-name:hover { color: var(--primary); text-decoration: none; }
.topic-card-matches { font-size: 16px; font-weight: 600; color: var(--muted); }
.topic-card-progress { display: flex; align-items: center; gap: 10px; margin-top: 2px; max-width: 260px; }
.topic-card-progress .bar { flex: 1; height: 6px; border-radius: 3px; }
.topic-card-progress .bar > span { border-radius: 3px; }
.progress-label { font-size: 16px; font-weight: 700; }
.progress-label:empty { display: none; }

/* Bottom: the list of sub-topics */
.topic-card-skills {
  border-top: 1px solid var(--border);
  background: var(--panel);
  padding: 10px 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.skill-line {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  padding: 0 8px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--ink);
}
.skill-line:hover { background: var(--soft); text-decoration: none; }
/* A sub-topic that matches the search */
.skill-line.match { background: var(--soft); font-weight: 800; }
.no-skills { padding: 6px 8px; font-size: 16px; font-weight: 600; color: var(--muted); }

/* The circle in front of each sub-topic. Done = filled with a check mark. */
.done-dot {
  flex: none;
  width: 18px;
  height: 18px;
  border-radius: 9px;
  border: 2px solid var(--ring);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--on-primary);
  font-size: 11px;
  font-weight: 800;
}
.done-dot.done { border-color: var(--primary); background: var(--primary); }

/* Fewer columns on smaller screens */
@media (max-width: 1200px) { .topic-columns { column-count: 3; } }
@media (max-width: 900px)  { .topic-columns { column-count: 2; } }
@media (max-width: 560px)  { .topic-columns { column-count: 1; } }
