/* The Academy hub as a route of stops, each with its own small stops on the same
   line. Space and one thin line do the grouping, so no section needs a box.
   The riding names are CSS sticky. A small script adds only the reader's own
   progress, so a first visit looks exactly the same without it. */
.ah {
  --ah-rail: 48px;      /* the strip that holds the line */
  --ah-line-at: 15px;   /* where the line runs inside that strip */
  --ah-band: 47px;      /* height of a stop's name when it rides along */
  --ah-col: 10.5rem;    /* the column of sub-section names */
  --ah-gap: 32px;       /* between that column and the guides */
  direction: rtl;
  color: var(--text-default);
  font-family: var(--font-body);
}
.ah * { box-sizing: border-box; }
.ah-open { max-width: 38rem; padding-block: var(--space-4) 44px; }
.ah-open h1 { font-family: var(--font-display); font-size: clamp(36px, 5vw, 52px); line-height: 1.15; margin: 0 0 12px; }
.ah-lead { font-size: 1.125rem; line-height: 1.65; color: var(--text-muted); margin: 0 0 24px; }

.ah-route { list-style: none; margin: 0; padding: 0; }
.ah-stop, .ah-guides > li { max-width: none; } /* the site caps every li at reading width */
.ah-stop { position: relative; padding-inline-start: var(--ah-rail); padding-block-end: 52px; }

/* The route: from this stop's marker down to the next one. The last stretch
   fades out instead of dead-ending. */
.ah-stop::before {
  content: '';
  position: absolute;
  inset-inline-start: var(--ah-line-at);
  top: 30px;
  bottom: -30px;
  width: 2px;
  border-radius: 2px;
  background: color-mix(in srgb, var(--brand-star) 45%, transparent);
}
.ah-stop:last-child { padding-block-end: 28px; }
.ah-stop:last-child::before {
  bottom: 0;
  background: linear-gradient(to bottom, color-mix(in srgb, var(--brand-star) 45%, transparent) 70%, transparent);
}

/* The stop's name and number ride down the line while its guides scroll past.
   The band covers only the content, so the line never breaks around the number. */
.ah-stop-head {
  position: sticky;
  top: 0;
  z-index: 2;
  padding-block: 14px 2px;
  background: var(--surface-page);
}
.ah-stop-head::after { /* guides dissolve as they pass under the name */
  content: '';
  position: absolute;
  inset-inline: 0;
  top: calc(100% - 1px); /* overlaps by a pixel: the band's height is fractional */
  height: 13px;
  pointer-events: none;
  background: linear-gradient(to bottom, var(--surface-page), transparent);
}
.ah-stop-head h2 { font-family: var(--font-display); font-size: 26px; line-height: 1.2; margin: 0; }
.ah-dot {
  position: absolute;
  inset-inline-start: calc(-1 * var(--ah-rail));
  top: 14px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-default);
  background: var(--surface-page);
  border: 2px solid var(--brand-star);
}
.ah-why { color: var(--text-muted); font-size: 0.95rem; line-height: 1.55; margin: 12px 0 26px; }

/* A sub-section: its own small stop on the line, its label beside it, its
   guides past that. Every guide on the page starts on the same edge. */
.ah-sub {
  display: grid;
  grid-template-columns: minmax(0, var(--ah-col)) minmax(0, 1fr);
  gap: var(--ah-gap);
  padding-block-end: 30px;
}
.ah-sub:last-child { padding-block-end: 0; }
.ah-sub-name {
  position: sticky;
  top: calc(var(--ah-band) + 16px);
  z-index: 1;
  align-self: start;
  margin: 0;
  padding-block-start: 1px;
  font-family: var(--font-body);
  font-size: 0.975rem;
  font-weight: 600;
  line-height: 1.45;
  color: var(--text-muted);
}
.ah-sub-name::before {
  content: '';
  position: absolute;
  inset-inline-start: calc(-1 * var(--ah-rail) + var(--ah-line-at) - 6px);
  top: 7px;
  box-sizing: border-box;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--surface-page);
  border: 2px solid var(--brand-star);
}

.ah-guides { list-style: none; margin: -10px 0 0; padding: 0; display: grid; gap: 2px; }
.ah-guide {
  display: block;
  padding: 10px 14px;
  margin-inline: -14px;
  border-radius: var(--radius-sm);
  color: inherit;
  text-decoration: none;
  scroll-margin-block-start: calc(var(--ah-band) + 16px); /* keyboard focus lands clear of the riding name */
  transition: background 0.15s ease-out;
}
.ah-guide:hover { background: color-mix(in srgb, var(--text-default) 6%, transparent); text-decoration: none; }
.ah-title { display: block; font-weight: 600; font-size: 1.0625rem; line-height: 1.45; color: var(--text-default); }
.ah-guide:hover .ah-title { color: var(--link); }
.ah-blurb { display: block; color: var(--text-muted); font-size: 0.92rem; line-height: 1.55; margin-block-start: 2px; }
.academy-hub-start { margin: 8px 0 0; padding-inline-start: var(--ah-rail); color: var(--text-muted); }

/* The reader's own route. Everything below appears only once a guide is finished. */
.ah-tally { margin: -8px 0 20px; font-weight: 600; color: var(--text-default); }
.ah-keep { margin: 10px 0 0; padding-inline-start: var(--ah-rail); color: var(--text-muted); font-size: 0.92rem; }
.ah-forget { padding: 0; border: 0; background: none; color: var(--link); font: inherit; text-decoration: underline; cursor: pointer; }

/* The lit stretch: one piece from the first stop to the furthest finished guide. */
.ah-route { position: relative; }
.ah-route::before {
  content: '';
  position: absolute;
  inset-inline-start: var(--ah-line-at);
  top: 30px;
  width: 2px;
  height: var(--ah-lit, 0px);
  border-radius: 2px;
  background: var(--brand-star);
}
.ah-route.is-drawing::before { transition: height 1.2s cubic-bezier(0.45, 0, 0.25, 1); }
.ah-route.has-progress .ah-stop::before { background: color-mix(in srgb, var(--brand-star) 32%, transparent); }
.ah-route.has-progress .ah-stop:last-child::before {
  background: linear-gradient(to bottom, color-mix(in srgb, var(--brand-star) 32%, transparent) 70%, transparent);
}
.ah-stop.is-lit .ah-dot { color: var(--color-ink); background: var(--brand-star); }
.ah-sub.is-lit .ah-sub-name::before { background: var(--brand-star); }

/* A group's first guide steps down, so its point clears the group's own ring. */
@media (min-width: 761px) {
  .ah-route.has-progress .ah-guides { margin-block-start: 20px; }
}

/* One point on the line per guide, level with its title. */
.ah-guide { position: relative; }
.ah-route.has-progress .ah-guide::before {
  --ah-size: 10px;
  content: '';
  position: absolute;
  top: calc(22px - var(--ah-size) / 2);
  inset-inline-start: calc(14px - var(--ah-rail) - var(--ah-col) - var(--ah-gap) + var(--ah-line-at) + 1px - var(--ah-size) / 2);
  box-sizing: border-box;
  width: var(--ah-size);
  height: var(--ah-size);
  border-radius: 50%;
  background: var(--surface-page);
  border: 2px solid color-mix(in srgb, var(--brand-star) 55%, var(--surface-page));
}
.ah-route.has-progress .ah-guide.is-read::before { background: var(--brand-star); border-color: var(--brand-star); }
.ah-route.has-progress .ah-guide.is-star::before {
  --ah-size: 24px;
  border: 0;
  border-radius: 0;
  background: var(--brand-star);
  clip-path: polygon(50% 0, 59% 41%, 100% 50%, 59% 59%, 50% 100%, 41% 59%, 0 50%, 41% 41%);
}
.ah-route.has-progress .ah-guide.is-new::before { animation: ah-pop 0.5s cubic-bezier(0.3, 1.6, 0.5, 1) var(--ah-pop-at, 0ms) backwards; }
@keyframes ah-pop { from { transform: scale(0.2) rotate(-120deg); opacity: 0; } to { transform: scale(1) rotate(0); opacity: 1; } }

@media (max-width: 760px) {
  .ah { --ah-rail: 44px; --ah-col: 0px; --ah-gap: 0px; }
  .ah-open { padding-block-end: 32px; }
  .ah-stop { padding-block-end: 36px; }
  .ah-why { margin-block-end: 20px; }
  .ah-sub { grid-template-columns: minmax(0, 1fr); gap: 12px; padding-block-end: 22px; }
  .ah-sub-name { position: relative; top: auto; }
  .academy-hub-start, .ah-keep { padding-inline-start: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .ah-guide { transition: none; }
  .ah-route.is-drawing::before { transition: none; }
  .ah-route.has-progress .ah-guide.is-new::before { animation: none; }
}

/* English site (spec 2026-11-14): the block is right-to-left by rule above; an English page turns it. */
.ah[dir='ltr'] { direction: ltr; }
