/* ==========================================================================
   Course list ("Μαθήματα") — Figma 82:2538, pillar page (#courses)
   Centred title, module filter buttons and a scrollable courses table.
   .course-filters     filter buttons (aria-pressed), "Όλα" + one per module
   .course-table       real <table>: #, title, module, level
   .course-list__scroll  scroll box (8 rows visible at 1920), slim custom
                       scrollbar next to the rows, sticky header
   Module colours: .module--1 … .module--4 set --module-color (tokens.css).
   Behaviour: js/course-list.js
   ========================================================================== */

.course-list {
  padding-block: 0 101px; /* top spacing comes from the practice section */
}

.course-list__title {
  text-align: center;
}

/* ---- Module colour ---------------------------------------------------------- */
.module--1 { --module-color: var(--module-1); }
.module--2 { --module-color: var(--module-2); }
.module--3 { --module-color: var(--module-3); }
.module--4 { --module-color: var(--module-4); }

/* ---- Filters ---------------------------------------------------------------- */
.course-filters {
  display: flex;
  flex-wrap: wrap; /* one row at 1920; wraps on laptops */
  gap: 10px;
  margin-top: 40px;
}

.course-filter {
  display: inline-flex;
  min-height: 47px;
  flex: none;
  align-items: center;
  gap: 15px;
  padding: 10px 20px 10px 11px;
  border: 0;
  background: var(--color-filter-bg);
  color: var(--color-filter-text);
  cursor: pointer;
  font-size: var(--font-size-base);
  white-space: nowrap;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.course-filter--all {
  padding-inline: 25px;
}

.course-filter:hover {
  background: color-mix(in srgb, var(--color-filter-bg), var(--color-table-head) 6%);
  color: var(--color-table-head);
}

.course-filter[aria-pressed="true"] {
  background: var(--accent-strong, var(--accent, var(--color-primary)));
  color: var(--white);
  font-weight: var(--font-weight-bold);
}

/* Icon in a tinted circle, in the module colour */
.course-filter__icon {
  display: grid;
  width: 27px;
  height: 27px;
  flex: none;
  border-radius: 13px;
  background: color-mix(in srgb, var(--module-color) 10%, transparent);
  place-items: center;
}

.course-filter[aria-pressed="true"] .course-filter__icon {
  background: var(--white);
}

/* ---- Table ------------------------------------------------------------------ */
/* Header 50px + 8 rows of 80px with 15px gaps = 810px (Figma) */
.course-list__scroll {
  max-height: 810px;
  margin-top: 40px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: var(--color-scroll-thumb) var(--color-scroll-track);
  scrollbar-width: thin;
}

.course-list__scroll::-webkit-scrollbar {
  width: 7px;
}

.course-list__scroll::-webkit-scrollbar-track {
  margin-top: 65px; /* the scrollbar runs next to the rows only */
  background: var(--color-scroll-track);
}

.course-list__scroll::-webkit-scrollbar-thumb {
  background: var(--color-scroll-thumb);
}

.course-table {
  width: 100%;
  margin-block: -15px; /* border-spacing adds 15px above and below the rows */
  border-collapse: separate;
  border-spacing: 0 15px;
  table-layout: fixed;
}

/* Columns: 30 + 58 | title | module | level (Figma's duration column replaced by the
   platform's difficulty level, on request) */
.course-table__col-number { width: 88px; }
.course-table__col-module { width: 420px; } /* module stays at its Figma x */
.course-table__col-level { width: 163px; }

.course-table th {
  position: sticky;
  z-index: 1;
  top: 0;
  height: 50px;
  padding: 0;
  border-bottom: 1px solid var(--color-table-rule);
  background: var(--color-bg);
  color: var(--color-table-head);
  font-size: 15px;
  font-weight: var(--font-weight-regular);
  text-align: start;
}

.course-table th:first-child,
.course-table td:first-child {
  padding-left: 30px;
}

.course-table td {
  height: 80px;
  padding: 0;
  background: var(--color-row-bg);
  white-space: nowrap;
}

.course-table tr[hidden] {
  display: none;
}

/* Number badge */
.course-table__number {
  display: grid;
  width: 30px;
  height: 30px;
  background: var(--color-row-number-bg);
  color: var(--color-primary);
  font-size: var(--font-size-sm);
  place-items: center;
}

/* Title (link to the course), one line with … */
.course-table__title {
  overflow: hidden;
  padding-right: 24px !important;
  color: var(--color-heading);
  font-size: 18px;
  text-overflow: ellipsis;
}

.course-table__title a:hover {
  color: var(--accent-strong, var(--color-primary));
}

/* Module: coloured dot + name */
.course-table__module {
  overflow: hidden;
  color: var(--color-filter-text);
  font-size: var(--font-size-base);
  text-overflow: ellipsis;
}

.course-table__module::before {
  display: inline-block;
  width: 11px;
  height: 11px;
  margin-right: 11px;
  border-radius: 50%;
  background: var(--module-color);
  content: "";
  vertical-align: -0.5px;
}

/* Level: 3 bars (1 = Αρχάριο, 2 = Μέσο, 3 = Προχωρημένο) + label */
.course-table__level {
  --bar-on: var(--color-table-head);
  --bar-off: var(--color-table-rule);
  --bar-1: var(--bar-on);
  --bar-2: var(--bar-off);
  --bar-3: var(--bar-off);

  color: var(--color-table-head);
  font-size: var(--font-size-base);
}

.course-table__level--2 { --bar-2: var(--bar-on); }
.course-table__level--3 { --bar-2: var(--bar-on); --bar-3: var(--bar-on); }

.course-table__level::before {
  display: inline-block;
  width: 14px;
  height: 12px;
  margin-right: 10px;
  background:
    linear-gradient(var(--bar-1), var(--bar-1)) 0 100% / 4px 5px no-repeat,
    linear-gradient(var(--bar-2), var(--bar-2)) 5px 100% / 4px 8px no-repeat,
    linear-gradient(var(--bar-3), var(--bar-3)) 10px 100% / 4px 12px no-repeat;
  content: "";
}

/* ---- Laptop ----------------------------------------------------------------- */
@media (max-width: 1500px) {
  .course-table__col-module { width: 28%; }

  /* long titles wrap instead of being cut */
  .course-table td.course-table__title {
    padding-block: 12px !important;
    white-space: normal;
    line-height: 1.35;
  }
  .course-table__col-level { width: 150px; }
}

/* ---- Tablet / phone: filters scroll sideways, each course as a card -------- */
@media (max-width: 1100px) {
  .course-list {
    padding-bottom: 72px;
  }

  .course-filters {
    flex-wrap: nowrap;
    overflow-x: auto;
    margin-inline: calc(-1 * var(--page-padding));
    padding-inline: var(--page-padding);
    scrollbar-width: none;
  }

  .course-filters::-webkit-scrollbar {
    display: none;
  }

  .course-list__scroll {
    max-height: 640px;
  }

  .course-list__scroll::-webkit-scrollbar-track {
    margin-top: 0;
  }

  .course-table,
  .course-table tbody {
    display: block;
    margin: 0;
  }

  .course-table thead,
  .course-table colgroup {
    display: none;
  }

  .course-table tbody {
    display: grid;
    gap: 10px;
    padding-right: 12px; /* room for the scrollbar */
  }

  /* number | title, then module | level */
  .course-table tr {
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px 14px;
    padding: 16px 20px;
    background: var(--color-row-bg);
  }

  .course-table td,
  .course-table td:first-child {
    height: auto;
    padding: 0 !important;
    background: none;
    white-space: normal;
  }

  .course-table__title {
    grid-column: 2 / -1;
    font-size: 17px;
    line-height: 1.35;
  }

  .course-table__module {
    grid-column: 2;
    font-size: var(--font-size-sm);
  }

  .course-table__level {
    grid-column: 3;
    font-size: var(--font-size-sm);
  }
}

/* ---- Phone ---------------------------------------------------------------- */
@media (max-width: 700px) {
  .course-list {
    padding-bottom: 56px;
  }

  .course-filters,
  .course-list__scroll {
    margin-top: 24px;
  }

  .course-table tr {
    padding: 16px;
  }

  .course-table__title {
    font-size: var(--font-size-base);
  }

  .course-table__module {
    white-space: nowrap;
  }
}
