/**
 * The course list, wherever courses are listed (includes/public/course-list.php):
 * subject pages, /courses/, site search, the online and adult lists.
 *
 * The subject page's list, as Simon chose it on 2026-11-19, made the one list
 * on 2026-11-24: a row per course, grouped (by level, or by subject on the
 * online list), the name underlined with its code under it, how it is taught,
 * how long, whose it is, and the Compare tick. On a phone the tick sits beside
 * the name and the length goes (his pick of the two phone rows on the design
 * canvas: "compare beside the name").
 *
 * COLOUR. Nothing here names a colour. An audience's colour is its route slot
 * (--route-1 to --route-5 in the theme's tokens, filled by each site from its
 * own palette); the rest is the theme's text, line and focus tokens.
 *
 * TYPE. Nothing under the theme's minimum (--fs-min). Rules that set type use
 * two classes, because some pages reset headings and links under a wrapper
 * with a class and an element, which outranks a lone class.
 */

/* ---- a route's colour ---- */
[data-route-slot="1"] { --route-bg: var(--route-1); --route-fg: var(--route-1-text); }
[data-route-slot="2"] { --route-bg: var(--route-2); --route-fg: var(--route-2-text); }
[data-route-slot="3"] { --route-bg: var(--route-3); --route-fg: var(--route-3-text); }
[data-route-slot="4"] { --route-bg: var(--route-4); --route-fg: var(--route-4-text); }
[data-route-slot="5"] { --route-bg: var(--route-5); --route-fg: var(--route-5-text); }

/* The square that carries a route's colour beside its name. */
.dncg-routes__key {
  flex: 0 0 auto;
  width: 1rem;
  height: 1rem;
  border-radius: 4px;
  background: var(--route-bg);
}

/* FE: the mark of a course listed in a view on request (the adults' view of a
   full-time course), in that view's colour pair, beside its label and on the
   notice. Letters, because an open square read as a tickbox. */
.dncg-list__fe {
  flex: 0 0 auto;
  display: inline-block;
  padding: 0 .3em;
  border-radius: 3px;
  background: var(--route-bg);
  color: var(--route-fg);
  font-size: var(--fs-min);
  font-weight: 800;
  line-height: 1.35;
  letter-spacing: .03em;
}

/* The list is shown and hidden in place, and its parts set displays of their
   own, which would otherwise win over the attribute. */
.dncg-clist [hidden],
.dncg-list [hidden],
.dncg-list[hidden] {
  display: none !important;
}

/* ---- the audience tabs: Show all courses, then a route each, in its colour ---- */
.dncg-routes__control {
  margin: 0 0 1.3rem;
}

.dncg-routes__control ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: .7rem;
  margin: 0;
  padding: 0;
}

.dncg-routes__control li {
  margin: 0;
}

.dncg-routes__control li::before {
  content: none;
}

.dncg-clist .dncg-routes__control a,
.dncg-subject-areas-archive-wrapper .dncg-routes__control a {
  display: flex;
  align-items: center;
  gap: .6rem;
  min-height: 2.75rem;
  padding: .6rem 1.15rem;
  border: 2px solid var(--control-border);
  border-radius: var(--radius-md);
  background: var(--white);
  font-size: 1.2rem;
  font-weight: 800;
  line-height: 1.2;
  color: var(--text-heading);
  text-decoration: none;
}

.dncg-clist .dncg-routes__control a:hover,
.dncg-subject-areas-archive-wrapper .dncg-routes__control a:hover {
  border-color: var(--text-heading);
}

/* The tab in play is filled with its route's colour; Show all courses, which
   has no colour of its own, with the site's dark. */
.dncg-clist .dncg-routes__control a[aria-current="true"],
.dncg-subject-areas-archive-wrapper .dncg-routes__control a[aria-current="true"] {
  border-color: var(--text-heading);
  background: var(--route-bg, var(--surface-dark-alt));
  color: var(--route-fg, var(--text-on-dark));
}

.dncg-routes__control a[aria-current="true"] .dncg-routes__key {
  display: none;
}

/* The choice in play is ticked as well as filled or tinted, in every row of
   choices (the tabs, How it's taught, Level), so colour is never the only
   sign of it (Simon, 2026-11-24). On a tab the tick takes the square's place.
   The tick is a mask over the text's own colour, so it follows the tab's
   colours on every site. */
.dncg-routes__control a[aria-current="true"]::before,
.dncg-list__how a[aria-current="true"]::before {
  content: "";
  flex: 0 0 auto;
  width: 1em;
  height: 1em;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9.5 18.6 3 12.1l2.3-2.3 4.2 4.2 9.2-9.2L21 7.1z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9.5 18.6 3 12.1l2.3-2.3 4.2 4.2 9.2-9.2L21 7.1z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.dncg-routes__control a:focus-visible,
.dncg-list__how a:focus-visible,
.dncg-list__link:focus-visible,
.dncg-list__more a:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.dncg-routes__n {
  font-weight: 600;
}

@media (max-width: 40em) {
  .dncg-routes__control ul {
    gap: .5rem;
  }

  .dncg-clist .dncg-routes__control a,
  .dncg-subject-areas-archive-wrapper .dncg-routes__control a {
    padding: .5rem .85rem;
    font-size: var(--fs-min);
  }
}

/* ---- How it's taught, and Level: the filters over the list ----
   A size quieter than the tabs, on purpose: who you are is the question,
   these only narrow the answer. Small outlined choices; the one in play is
   tinted, never filled dark as the tab in play is. */
.dncg-list__how {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .4rem .9rem;
  margin: 0 0 1.2rem;
}

.dncg-list__how-label {
  font-size: var(--fs-min);
  color: var(--muted);
}

.dncg-list__how ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin: 0;
  padding: 0;
}

.dncg-list__how li {
  margin: 0;
}

.dncg-list__how li::before {
  content: none;
}

.dncg-list .dncg-list__how a {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  min-height: 2.4rem;
  padding: .15rem .85rem;
  border: 1px solid var(--control-border);
  border-radius: var(--radius-pill);
  background: var(--white);
  font-size: var(--fs-min);
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
}

.dncg-list .dncg-list__how a:hover {
  border-color: var(--text-heading);
  color: var(--text-heading);
}

/* The second line of the border is drawn inside, so choosing one does not
   nudge its neighbours. */
.dncg-list .dncg-list__how a[aria-current="true"] {
  border-color: var(--text-heading);
  background: var(--light);
  box-shadow: inset 0 0 0 1px var(--text-heading);
  color: var(--text-heading);
}

/* ---- what "on request" means, in the views that list courses on request ---- */
.dncg-list .dncg-list__notice {
  display: flex;
  align-items: baseline;
  gap: .6rem;
  max-width: 62ch;
  margin: 0 0 1.4rem;
  font-size: var(--fs-min);
  line-height: 1.5;
  color: var(--text);
}

/* ---- the list ---- */

/* A group: a rule, its name once, and its courses beside it. The name and
   the first course sit on one baseline, whatever their sizes. */
.dncg-list {
  border-bottom: 2px solid var(--text-heading);
}

.dncg-list__level {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 2rem;
  border-top: 2px solid var(--text-heading);
  scroll-margin-top: 6rem;
}

.dncg-list__rail {
  flex: 0 0 9.5rem;
}

.dncg-list .dncg-list__level-name {
  font-family: var(--font-display);
  font-weight: var(--display-weight);
  font-size: 1.5rem;
  line-height: 1.15;
  color: var(--text-heading);
  margin: 0;
}

/* Grouped by subject (the online and adult lists): subject names are longer
   than "Level 2", so their column is wider and their type a step smaller. */
.dncg-list--by-subject .dncg-list__rail {
  flex-basis: 15rem;
}

.dncg-list.dncg-list--by-subject .dncg-list__level-name {
  font-size: 1.35rem;
}

.dncg-list__body {
  flex: 999 1 30rem;
  min-width: 0;
}

.dncg-list__rows {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* A course: its name (with its code under it) and the Compare tick on one
   line, then how it is taught, how long and whose it is. Wide (the last rule
   of this sheet): fixed columns, so every row's facts line up. */
.dncg-list .dncg-list__row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .1rem 1.3rem;
  margin: 0;
  padding: .9rem 0;
  border-bottom: 1px solid var(--line);
  font-size: var(--fs-min);
  line-height: 1.4;
}

.dncg-list .dncg-list__row::before {
  content: none;
}

/* The line break after the name and the tick. */
.dncg-list .dncg-list__row::after {
  content: "";
  flex: 0 0 100%;
  order: 1;
  height: 0;
}

.dncg-list__mode,
.dncg-list__length,
.dncg-list__who {
  order: 2;
}

/* The last course showing in a group: the next group's rule follows it. */
.dncg-list .dncg-list__row[data-last] {
  border-bottom: 0;
}

/* The name's place in the row: the name, and under it the course code. */
.dncg-list__name {
  flex: 1 1 0;
  min-width: 0;
}

/* The course code: small, grey and not a link, for whoever has to quote it. */
.dncg-list__code {
  display: block;
  margin-top: .2rem;
  font-size: var(--fs-min);
  font-weight: 400;
  color: var(--muted);
}

/* The name is the link, and is underlined so it looks like one. */
.dncg-list .dncg-list__link {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text-heading);
  text-decoration: underline;
  text-decoration-thickness: .07em;
  text-underline-offset: .2em;
}

.dncg-list .dncg-list__link:hover {
  color: var(--blue-text);
  text-decoration-thickness: .14em;
}

.dncg-list__mode {
  color: var(--text);
}

/* Online is the answer people scan this column for: in the site's blue, at
   the column's own weight (bold read as a link, Simon, 2026-11-24). */
.dncg-list__mode--online {
  color: var(--blue-text);
}

.dncg-list__length {
  color: var(--muted);
}

.dncg-list__who {
  display: flex;
  flex-wrap: wrap;
  gap: .15rem 1rem;
  font-weight: 700;
  color: var(--text-heading);
}

.dncg-list__route,
.dncg-list__where {
  display: flex;
  align-items: baseline;
  gap: .5rem;
}

.dncg-list__who .dncg-routes__key {
  width: .85rem;
  height: .85rem;
  border-radius: 3px;
  transform: translateY(.06rem);
}

/* With one route showing, every row is that route's, so its name goes; the
   column itself goes too unless the courses in view are taught at more than
   one place (it says where), or some are there on request (it says so). */
.dncg-list:not([data-current="all"]) .dncg-list__route:not(.dncg-list__route--also),
.dncg-list:not([data-current="all"]):not(.dncg-list--where):not(.dncg-list--also) .dncg-list__who {
  display: none;
}

/* This site's own name beside its own courses: only where the courses in
   view are a mix of here and elsewhere, and one route is showing. */
.dncg-list__where--here {
  display: none;
}

.dncg-list:not([data-current="all"]).dncg-list--where .dncg-list__where--here {
  display: flex;
}

/* Columns a list does without (the online list: no audience, no way of
   studying, since every course there is the same). */
.dncg-list--no-who .dncg-list__who,
.dncg-list--no-mode .dncg-list__mode,
.dncg-list--no-length .dncg-list__length {
  display: none;
}

/* The compare tick (dncg-course-compare fills the slot). On a card it is in
   the link colour; forty of those down a list would shout over the courses,
   so here it is quiet until it is ticked. */
.dncg-list__compare {
  flex: 0 0 auto;
}

.dncg-list__compare:empty {
  display: none;
}

.dncg-list__compare .dncg-cc-check {
  padding: 0;
  font-weight: 600;
  color: var(--muted);
}

.dncg-list__compare .dncg-cc-check.is-on {
  font-weight: 700;
  color: var(--text-heading);
}

/* A long group folded: the link to the rest of it. */
.dncg-list .dncg-list__more {
  margin: 0;
  padding: .2rem 0 1rem;
  font-size: var(--fs-min);
}

.dncg-list .dncg-list__more a {
  font-weight: 700;
  color: var(--blue-text);
  text-decoration: underline;
  text-underline-offset: .2em;
}

/* Narrow: the group's name over its courses, with the room a row has. */
@media (max-width: 48em) {
  .dncg-list__rail {
    flex: 1 1 100%;
    padding-top: .9rem;
  }
}

/* A phone: the length goes where the row has other facts to give. */
@media (max-width: 40em) {
  .dncg-list:not(.dncg-list--no-mode) .dncg-list__length {
    display: none;
  }
}

/* Wide: columns. The fourth (whose course, or where) is only there when it
   has something to say; the tick is always the last. */
@media (min-width: 75em) {
  .dncg-list .dncg-list__row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 7.5rem 7.5rem 11.5rem 6.5rem;
    gap: 0 1.4rem;
  }

  .dncg-list .dncg-list__row::after {
    content: none;
  }

  .dncg-list:not([data-current="all"]):not(.dncg-list--where):not(.dncg-list--also) .dncg-list__row {
    grid-template-columns: minmax(0, 1fr) 7.5rem 7.5rem 6.5rem;
  }

  /* No audience column at all (the adult list): the length takes its room,
     since some lengths there are a few words ("2 days per week"). */
  .dncg-list.dncg-list--no-who .dncg-list__row {
    grid-template-columns: minmax(0, 1fr) 7.5rem 11rem 6.5rem;
  }

  .dncg-list.dncg-list--no-who.dncg-list--no-mode .dncg-list__row {
    grid-template-columns: minmax(0, 1fr) 13rem 6.5rem;
  }

  .dncg-list.dncg-list--no-mode:not(.dncg-list--no-who) .dncg-list__row {
    grid-template-columns: minmax(0, 1fr) 9rem 11.5rem 6.5rem;
  }

  .dncg-list__who {
    flex-direction: column;
    flex-wrap: nowrap;
  }

  /* Second in the markup, so it is beside the name on a phone; the last
     column here. */
  .dncg-list__compare {
    grid-column: -2;
    grid-row: 1;
    justify-self: end;
  }

  .dncg-list__compare:empty {
    display: block;
  }
}
