/* Horaires officiels (src/views/timetable-hours.mjs) : un bloc par niveau, un anneau avec le
   pourcentage au centre, une ligne par domaine à la couleur de sa matière, son nom sur une seule
   ligne, en petit. Les jauges : le trait marque l'horaire officiel, la barre s'arrête avant ou le
   dépasse (hachurée), le pourcentage au bout, teinté selon l'écart (vert : juste, orange : il
   manque, bleu : de plus). « Seulement l'écart » : à gauche ce qui manque, à droite ce qui
   dépasse, à la couleur de la matière. Le reste est dans la bulle. */
.hours-kpi {
  --hk-ok: #1b6b47;
  --hk-short: #8a4a00;
  --hk-over: #1f5fbf;
}
.hk-views {
  margin: 4px 0 0;
}
.hk-levels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 330px), 1fr));
  gap: 14px;
  margin-top: 10px;
}
.hk-level {
  min-width: 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--c-primary, var(--primary)) 6%, var(--panel, #fff));
}
.hk-level > header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  border-radius: 10px;
  cursor: default;
}
.hk-level h3 {
  margin: 0;
  font-size: 15px;
}
.hk-level header p {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--ox-quiet, #6b6478);
  font-variant-numeric: tabular-nums;
}
/* L'anneau : le cercle est dessiné derrière (::before, masqué au centre), le pourcentage devant. */
.hk-ring {
  position: relative;
  display: grid;
  flex: none;
  place-items: center;
  width: 58px;
  height: 58px;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.hk-ring::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(
    var(--c-primary, var(--primary)) calc(var(--hk-ratio) * 360deg),
    color-mix(in srgb, var(--c-primary, var(--primary)) 16%, var(--panel, #fff)) 0
  );
  mask: radial-gradient(farthest-side, transparent 74%, #000 76%);
}
.hk-ring > span {
  position: relative;
}
.hk-list {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.hk-row {
  display: grid;
  grid-template-columns: minmax(0, 15em) minmax(60px, 1fr);
  align-items: center;
  gap: 0 10px;
  min-height: 26px;
  margin: 0;
  padding: 0 4px;
  border-radius: 8px;
  font-size: 12px;
  cursor: default;
}
.hk-row:hover,
.hk-row:focus-visible,
.hk-level > header:focus-visible {
  background: color-mix(in srgb, var(--c-primary, var(--primary)) 9%, transparent);
}
/* Le nom sur une seule ligne ; s'il est trop long, il se coupe (la bulle le donne en entier). */
.hk-row > .subject-tag {
  min-width: 0;
}
.hk-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hk-bar {
  position: relative;
  height: 9px;
  margin-right: 3.4em;
  border-radius: 99px;
  background: color-mix(in srgb, var(--discipline-color, var(--primary)) 16%, var(--panel, #fff));
}
.hk-bar > i,
.hk-bar > u {
  position: absolute;
  top: 0;
  bottom: 0;
}
.hk-bar > i {
  left: 0;
  border-radius: 99px;
  background: var(--discipline-color, var(--primary));
}
.hk-bar > u {
  border-radius: 0 99px 99px 0;
  background: repeating-linear-gradient(
    135deg,
    var(--discipline-color, var(--primary)) 0 3px,
    color-mix(in srgb, var(--discipline-color, var(--primary)) 40%, var(--panel, #fff)) 3px 6px
  );
}
.hk-bar > b {
  position: absolute;
  top: -4px;
  bottom: -4px;
  width: 2px;
  margin-left: -1px;
  border-radius: 1px;
  background: var(--ink, #3a2b52);
  opacity: 0.75;
}
/* Le chiffre au bout : le pourcentage (jauges) ou l'écart en durée (seulement l'écart). */
.hk-end {
  position: absolute;
  top: 50%;
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  translate: 6px -50%;
}
[data-hk-state='ok'] .hk-end {
  color: var(--hk-ok);
}
[data-hk-state='short'] .hk-end {
  color: var(--hk-short);
}
[data-hk-state='over'] .hk-end {
  color: var(--hk-over);
}
/* Seulement l'écart : le trait de l'horaire officiel au milieu. */
.hk-gap {
  position: relative;
  height: 12px;
}
.hk-gap::before {
  content: '';
  position: absolute;
  top: -5px;
  bottom: -5px;
  left: 50%;
  width: 2px;
  margin-left: -1px;
  border-radius: 1px;
  background: var(--ink, #3a2b52);
  opacity: 0.6;
}
.hk-gap > i {
  position: absolute;
  top: 1px;
  bottom: 1px;
  background: var(--discipline-color, var(--primary));
}
.hk-gap-short {
  right: 50%;
  border-radius: 99px 0 0 99px;
  opacity: 0.55;
}
.hk-gap-over {
  left: 50%;
  border-radius: 0 99px 99px 0;
}
.hk-gap > .hk-gap-ok {
  left: 50%;
  width: 10px;
  margin-left: -5px;
  border-radius: 50%;
}
.hk-gap-end-short {
  right: calc(50% + var(--hk-size));
  translate: -6px -50%;
}
.hk-gap-end-over {
  left: calc(50% + var(--hk-size));
}
.hk-axis {
  display: grid;
  grid-template-columns: minmax(0, 15em) 1fr 1fr 1fr;
  gap: 0 10px;
  margin: 4px 0 0;
  padding: 0 4px;
  font-size: 10.5px;
  color: var(--ox-quiet, #6b6478);
}
.hk-axis > span:first-child {
  grid-column: 2;
}
.hk-axis > span:nth-child(2) {
  text-align: center;
}
.hk-axis > span:last-child {
  text-align: right;
}
.hk-others,
.hk-source {
  margin: 10px 0 0;
  font-size: 12.5px;
  color: var(--ox-quiet, #6b6478);
}
.hk-source > a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}
@media (max-width: 640px) {
  .hk-row,
  .hk-axis {
    grid-template-columns: minmax(0, 8.5em) minmax(0, 1fr);
  }
  .hk-axis {
    grid-template-columns: minmax(0, 8.5em) 1fr 1fr 1fr;
    gap: 0 4px;
  }
}
