/**
 * djtutor.com :: learning-path module (mod_djtutor_path)
 *
 * The curriculum as a numbered route. Built only from the --djt-* design tokens, so it follows the
 * brand and the light/dark scheme without redefining either.
 *
 * The route: every step carries its number as a node that sits on the card's top edge, and a short
 * thread runs from each node through the gap to the next card. In the single-column layout the
 * thread runs downwards, in the grid it runs along each row. Ready stages (with a course) are solid
 * brand nodes on white; stages still in preparation are dashed outlines on the tinted surface.
 */

.djt-path {
  --_gap: clamp(1.25rem, 2.4vw, 1.75rem);
  --_node: 2.75rem;                /* diameter of the number node */
  --_node-x: 1.25rem;              /* node offset from the card's left edge */

  padding: clamp(3rem, 6vw, 4.5rem) 0 clamp(2.5rem, 5vw, 4rem);
}

/* ---------------------------------------------------------------- intro -- */

.djt-path__intro {
  max-width: 68ch;
  margin: 0 0 clamp(2rem, 4vw, 2.75rem);
}

/* heading + standfirst share the template's section-heading treatment (see tpl djtutor.css) */
.djt-path__heading {
  margin: 0 0 .6rem;
  font-size: var(--djt-fs-2xl, 1.75rem);
  line-height: var(--djt-lh-tight, 1.15);
  letter-spacing: -.015em;
  color: var(--djt-text-strong, #0b1220);
}

.djt-path__standfirst {
  max-width: 62ch;
  margin: 0;
  font-size: var(--djt-fs-md, 1rem);
  line-height: var(--djt-lh-body, 1.6);
  color: var(--djt-muted, #5b6578);
}

/* ---------------------------------------------------------------- steps -- */

.djt-path__list {
  display: grid;
  gap: var(--_gap);
  grid-template-columns: minmax(0, 1fr);
  margin: 0;
  padding: calc(var(--_node) / 2) 0 0;   /* room for the first row of nodes */
  list-style: none;                       /* the numbers are rendered explicitly */
}

@media (min-width: 48rem) {
  .djt-path__list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 70rem) {
  .djt-path__list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.djt-path__step {
  position: relative;
  display: block;
  padding: calc(var(--_node) / 2 + .875rem) 1.375rem 1.375rem;
  background: var(--djt-surface, #fff);
  border: 1px solid var(--djt-border, #d8dfea);
  border-radius: var(--djt-radius-lg, 1rem);
  transition: border-color var(--djt-dur, .18s) ease, box-shadow var(--djt-dur, .18s) ease, transform var(--djt-dur, .18s) ease;
}

.djt-path__step:hover,
.djt-path__step:focus-within {
  border-color: var(--djt-border-strong, #b7c2d4);
  box-shadow: var(--djt-shadow, 0 8px 24px rgba(13, 32, 69, .10));
  transform: translateY(-2px);
}

/* stages without a course yet: quieter, dashed */
.djt-path__step.is-pending {
  background: var(--djt-surface-2, #f4f7fc);
  border-style: dashed;
}

/* --------------------------------------------------------------- thread -- */

/* single column: the thread drops from the node down to the next card */
.djt-path__step::before {
  content: "";
  position: absolute;
  z-index: 0;
  top: 100%;
  left: calc(var(--_node-x) + var(--_node) / 2 - 1px);
  width: 2px;
  height: var(--_gap);
  background: var(--djt-border-strong, #b7c2d4);
}

.djt-path__step:last-child::before {
  display: none;
}

/* two and three columns: the thread runs along the row at node height */
@media (min-width: 48rem) {
  .djt-path__step::before {
    top: -1px;
    left: 100%;
    width: var(--_gap);
    height: 2px;
  }

  .djt-path__step:nth-child(2n)::before {
    display: none;
  }
}

@media (min-width: 70rem) {
  .djt-path__step:nth-child(2n)::before {
    display: block;
  }

  .djt-path__step:nth-child(3n)::before {
    display: none;
  }
}

/* --------------------------------------------------------------- marker -- */

.djt-path__marker {
  position: absolute;
  top: calc(var(--_node) / -2);
  left: var(--_node-x);
  z-index: 1;
  display: grid;
  place-items: center;
  width: var(--_node);
  height: var(--_node);
  border-radius: var(--djt-radius-pill, 999px);
  background: var(--djt-surface, #fff);
  border: 2px dashed var(--djt-border-strong, #b7c2d4);
  color: var(--djt-muted, #5b6578);
  box-shadow: 0 0 0 4px var(--djt-bg, #fff);
  font-variant-numeric: tabular-nums;
}

.djt-path__num {
  font-size: var(--djt-fs-lg, 1.125rem);
  font-weight: 800;
  line-height: 1;
}

.is-ready > .djt-path__marker {
  background: var(--djt-brand, #2152ad);
  border: 2px solid var(--djt-brand, #2152ad);
  color: var(--djt-on-ink, #fff);
}

.djt-path__step.is-ready:hover > .djt-path__marker {
  background: var(--djt-brand-hover, #16397a);
  border-color: var(--djt-brand-hover, #16397a);
}

/* ----------------------------------------------------------------- body -- */

.djt-path__step-label {
  display: block;
  margin-bottom: .2rem;
  font-size: var(--djt-fs-xs, .75rem);
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--djt-ink, #2152ad);
}

.is-pending .djt-path__step-label {
  color: var(--djt-muted, #5b6578);
}

.djt-path__title {
  margin: 0 0 .45rem;
  font-size: var(--djt-fs-lg, 1.125rem);
  font-weight: 600;
  line-height: var(--djt-lh-snug, 1.3);
  letter-spacing: -.005em;
}

.djt-path .djt-path__title a {
  color: var(--djt-text-strong, #0b1220);
  text-decoration: none;
}

.djt-path .djt-path__title a:hover {
  color: var(--djt-ink, #2152ad);
}

/* Make the whole card clickable without nesting interactive elements. */
.djt-path .djt-path__title a::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: inherit;
}

.djt-path .djt-path__title a:focus-visible {
  outline: none;
}

.djt-path__step:has(.djt-path__title a:focus-visible) {
  outline: 3px solid var(--djt-focus, #2152ad);
  outline-offset: 3px;
}

/* browsers without :has() still get a ring, on the pseudo-element that covers the card */
@supports not selector(:has(a)) {
  .djt-path .djt-path__title a:focus-visible::after {
    outline: 3px solid var(--djt-focus, #2152ad);
    outline-offset: 3px;
  }
}

.djt-path__text {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
  margin: 0 0 .8rem;
  font-size: var(--djt-fs-sm, .875rem);
  line-height: var(--djt-lh-body, 1.6);
  color: var(--djt-muted, #5b6578);
}

.djt-path__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .3rem .45rem;
  margin: 0;
  font-size: var(--djt-fs-xs, .75rem);
}

.djt-path__stat {
  padding: .15rem .55rem;
  border-radius: var(--djt-radius-pill, 999px);
  background: var(--djt-badge-bg, #e9f0fb);
  color: var(--djt-badge-fg, #16397a);
  font-weight: 700;
  letter-spacing: .02em;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.djt-path__stat--soon {
  background: var(--djt-badge-soon-bg, #fef3c7);
  color: var(--djt-badge-soon-fg, #7c4a03);
}

.djt-path__stat--muted {
  padding-inline: .15rem;
  background: transparent;
  color: var(--djt-muted, #5b6578);
  font-weight: 500;
}

/* ------------------------------------------------------------------ cta -- */

.djt-path__cta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  margin-top: clamp(2rem, 4vw, 2.75rem);
  padding: clamp(1.25rem, 3vw, 1.75rem) clamp(1.25rem, 3vw, 2rem);
  background: var(--djt-ink-soft, #e9f0fb);
  border-radius: var(--djt-radius-lg, 1rem);
}

.djt-path__cta-text {
  flex: 1 1 28rem;
}

.djt-path__cta-title {
  margin: 0 0 .3rem;
  font-size: var(--djt-fs-xl, 1.375rem);
  line-height: var(--djt-lh-snug, 1.3);
  letter-spacing: -.01em;
  color: var(--djt-text-strong, #0b1220);
}

.djt-path__cta p {
  max-width: 62ch;
  margin: 0;
  font-size: var(--djt-fs-sm, .875rem);
  line-height: var(--djt-lh-body, 1.6);
  color: var(--djt-muted, #5b6578);
}

.djt-path__cta .djt-btn {
  position: relative;
  z-index: 1;
}

@media (prefers-reduced-motion: reduce) {
  .djt-path__step { transition: none; }
  .djt-path__step:hover,
  .djt-path__step:focus-within { transform: none; }
}
