/* The cycle of the software factory: the ruby at the center, the stages around it and the signals that run between
   them. The course page shows the full figure and its synthesis. The home shows the cycle as a score, in one of its openings. */
/* O movimento ilustra o ciclo: direção humana estável, trabalho contínuo entre etapas. */
.course-cycle {
  --cycle-play-state: paused;
  position: relative;
  min-width: 0;
  margin: 0;
  padding: var(--space-l);
  border: var(--border-thin) solid var(--ink);
  border-radius: var(--radius-panel);
  background: var(--panel-bg);
  color: var(--panel-text);
  overflow: hidden;
  container-type: inline-size;
}
.course-cycle[data-cycle-running="true"] { --cycle-play-state: running; }
.course-cycle__direction { position: relative; z-index: 2; display: flex; justify-content: space-between; align-items: center; gap: var(--space-m); }
.course-cycle__orchestrator { display: flex; align-items: center; gap: var(--space-s); }
.course-cycle__orchestrator > .icon { color: var(--panel-title); }
.course-cycle__orchestrator strong { display: block; color: var(--panel-title); font-size: var(--fs-control-large); line-height: var(--lh-ui-title); }
.course-cycle__orchestrator span { display: block; margin-top: 4px; font-size: var(--fs-caption); }
.course-cycle__toggle { display: grid; place-items: center; flex: none; width: var(--target-size); height: var(--target-size); padding: 0; border: 1px solid var(--terminal-rule); border-radius: 50%; background: transparent; color: var(--panel-text); cursor: pointer; }
.course-cycle__toggle:hover { background: var(--terminal-rule); }
.course-cycle__toggle:focus-visible { outline-color: var(--panel-text); }
.course-cycle__toggle[hidden], .course-cycle__play-icon { display: none; }
.course-cycle[data-cycle-paused="true"] .course-cycle__pause-icon { display: none; }
.course-cycle[data-cycle-paused="true"] .course-cycle__play-icon { display: block; }
.course-cycle__map { position: relative; isolation: isolate; aspect-ratio: 1; margin-top: var(--space-m); }
.course-cycle__map::before { content: ""; position: absolute; top: 0; left: 50%; height: 36%; width: 1px; background: linear-gradient(var(--panel-title), transparent); }
.course-cycle__connections { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; fill: none; }
.course-cycle__connections--wide { display: none; }
.course-cycle__spokes { stroke: var(--terminal-rule); stroke-width: 1; stroke-dasharray: 3 8; }
.course-cycle__orbit { stroke: var(--terminal-rule); stroke-width: 1.5; }
.course-cycle__orbit--inner { stroke-dasharray: 2 10; }
.course-cycle__arrows { stroke: var(--panel-title); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.course-cycle__signal { stroke-width: 3; stroke-linecap: round; animation: cycle-signal 2.8s linear infinite; }
.course-cycle__signal--outer { stroke: var(--ai-spectrum-cyan); stroke-dasharray: 9 41; }
.course-cycle__signal--inner { stroke: var(--ai-spectrum-magenta); stroke-dasharray: 5 28.333; animation-duration: 4.2s; }
.course-cycle__wave { stroke: var(--ai-spectrum-violet); stroke-width: 1; transform-origin: center; opacity: 0; animation: cycle-wave 5s ease-out infinite; }
.course-cycle__wave--second { stroke: var(--ai-spectrum-cyan); animation-delay: -2.5s; }
.course-cycle__aura { position: absolute; inset: 24%; border-radius: 50%; background: conic-gradient(from 45deg, var(--ai-spectrum-gold), var(--ai-spectrum-magenta), var(--ai-spectrum-violet), var(--ai-spectrum-cyan), var(--ai-spectrum-gold)); filter: blur(28px); opacity: .2; animation: cycle-aura 18s linear infinite; }
.course-cycle__steps { margin: 0; list-style: none; }
.course-cycle__steps li { position: absolute; z-index: 2; display: grid; justify-items: center; gap: var(--space-xs); width: 29%; padding: var(--space-s) 4px; border: 1px solid var(--terminal-rule); border-radius: var(--radius-btn); background: var(--panel-bg); transform: translate(-50%, -50%); animation: cycle-stage 9s ease-in-out infinite; }
.course-cycle__steps li:nth-child(1) { left: 50%; top: 15.33%; animation-delay: 0s; }
.course-cycle__steps li:nth-child(2) { left: 80%; top: 32.67%; animation-delay: -7.5s; }
.course-cycle__steps li:nth-child(3) { left: 80%; top: 67.33%; animation-delay: -6s; }
.course-cycle__steps li:nth-child(4) { left: 50%; top: 84.67%; animation-delay: -4.5s; }
.course-cycle__steps li:nth-child(5) { left: 20%; top: 67.33%; animation-delay: -3s; }
.course-cycle__steps li:nth-child(6) { left: 20%; top: 32.67%; animation-delay: -1.5s; }
.course-cycle__steps .icon { color: var(--panel-title); }
.course-cycle__steps h3 { font-size: clamp(var(--fs-caption), 3.3cqi, var(--fs-control-large)); line-height: var(--lh-ui-title); white-space: nowrap; }
.course-cycle__core { position: absolute; z-index: 1; left: 50%; top: 50%; width: 44%; transform: translate(-50%, -50%); display: grid; justify-items: center; gap: var(--space-xs); text-align: center; }
.course-cycle__ruby { width: 44%; height: auto; animation: cycle-pulse 3s ease-in-out infinite; }
.course-cycle__core strong { max-width: 10ch; color: var(--surface); font-size: clamp(var(--fs-control), 4.5cqi, var(--fs-card-title)); line-height: var(--lh-ui-title); }
.course-cycle__activity { position: absolute; z-index: 3; display: grid; place-items: center; width: 32px; height: 32px; border: 1px solid var(--ai-spectrum-cyan); border-radius: var(--radius-btn); background: var(--panel-bg); color: var(--ai-spectrum-cyan); opacity: 0; animation: cycle-activity 9s ease-in-out infinite; }
.course-cycle__activity:nth-child(1) { left: 65%; top: 18%; animation-delay: -7.5s; }
.course-cycle__activity:nth-child(2) { left: 79%; top: 47%; animation-delay: -6s; }
.course-cycle__activity:nth-child(3) { left: 25%; top: 76%; animation-delay: -3s; }
.course-cycle__caption { position: relative; display: grid; gap: var(--space-xs); padding-top: var(--space-m); border-top: 1px solid var(--terminal-rule); font-size: var(--fs-caption); line-height: var(--lh-caption); }
.course-cycle__caption strong { color: var(--panel-title); font-size: var(--fs-control-large); }
.course-cycle :is(.course-cycle__signal, .course-cycle__wave, .course-cycle__aura, .course-cycle__steps li, .course-cycle__ruby, .course-cycle__activity) { animation-play-state: var(--cycle-play-state); }
@keyframes cycle-signal { to { stroke-dashoffset: -100; } }
@keyframes cycle-aura { to { transform: rotate(360deg); } }
@keyframes cycle-pulse { 0%, 100% { transform: scale(.96); } 50% { transform: scale(1.06); } }
@keyframes cycle-wave { 0% { transform: scale(.65); opacity: 0; } 20% { opacity: .45; } 100% { transform: scale(2.05); opacity: 0; } }
@keyframes cycle-stage { 0%, 24%, 100% { border-color: var(--terminal-rule); } 8%, 16% { border-color: var(--panel-title); } }
@keyframes cycle-activity { 0%, 28%, 100% { opacity: 0; transform: translateY(6px) scale(.8); } 8%, 20% { opacity: 1; transform: translateY(0) scale(1); } }

@media (prefers-reduced-motion: reduce) {
  .course-cycle *, .course-cycle *::before { animation: none !important; }
  .course-cycle__toggle, .course-cycle__activities, .course-cycle__wave { display: none; }
}

@media (max-width: 1000px) {
  .course-cycle { max-width: 40rem; width: 100%; }
}

@media (max-width: 560px) {
  .course-cycle { padding: var(--space-m); }
  .course-cycle__steps li { padding: var(--space-xs) 2px; gap: 4px; width: 31%; }
  .course-cycle__steps .icon { display: none; }
  .course-cycle__core { gap: 4px; }
  .course-cycle__ruby { width: 40%; }
  /* Sem a gema no ciclo completo, o nome do núcleo cresce com a largura do ciclo. */
  .course-cycle__core strong { font-size: clamp(var(--fs-control-large), 6.5cqi, var(--fs-card-title)); }
  .course-cycle__activity { width: 26px; height: 26px; }
  .course-cycle__orchestrator > .icon { display: none; }
}

@media (min-width: 1001px) {
  .course-cycle__direction { justify-content: center; }
  .course-cycle__toggle { position: absolute; right: 0; }
  .course-cycle__map { aspect-ratio: 10 / 3; margin-block: var(--space-s); }
  .course-cycle__map::before { height: 50%; }
  .course-cycle__connections--round { display: none; }
  .course-cycle__connections--wide { display: block; }
  .course-cycle__steps li { display: flex; justify-content: center; align-items: center; gap: var(--space-s); width: 19%; padding: var(--space-m) var(--space-xs); }
  .course-cycle__steps li:nth-child(1) { left: 20%; top: 20%; }
  .course-cycle__steps li:nth-child(2) { left: 50%; top: 20%; }
  .course-cycle__steps li:nth-child(3) { left: 80%; top: 20%; }
  .course-cycle__steps li:nth-child(4) { left: 80%; top: 80%; }
  .course-cycle__steps li:nth-child(5) { left: 50%; top: 80%; }
  .course-cycle__steps li:nth-child(6) { left: 20%; top: 80%; }
  .course-cycle__core { display: flex; align-items: center; gap: var(--space-m); width: max-content; max-width: 60%; }
  .course-cycle__ruby { flex: none; width: calc(var(--space-xl) * 1.5); }
  .course-cycle__core strong { max-width: none; white-space: nowrap; font-size: var(--fs-card-title); }
  .course-cycle__aura { inset: 10% 33%; }
  .course-cycle__activity:nth-child(1) { left: 33.5%; top: 15%; }
  .course-cycle__activity:nth-child(2) { left: 91.5%; top: 45%; }
  .course-cycle__activity:nth-child(3) { left: 33.5%; top: 75%; }
  .course-cycle__caption { grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); align-items: center; gap: var(--space-l); }
}

/* Síntese do ciclo no fechamento: ícones estáveis, ruby central e conexões em movimento. */
.course-cycle--mini { width: 100%; max-width: 20rem; padding: 0; border: 0; border-radius: 0; background: transparent; overflow: visible; }
.course-cycle--mini .course-cycle__direction { position: absolute; inset: 0 0 auto auto; }
.course-cycle--mini .course-cycle__toggle { position: relative; }
.course-cycle--mini .course-cycle__map { aspect-ratio: 1; margin: 0; }
.course-cycle--mini .course-cycle__map::before { display: none; }
.course-cycle--mini .course-cycle__connections--round { display: block; }
.course-cycle--mini .course-cycle__aura { inset: 24%; }
.course-cycle--mini .course-cycle__steps li { display: grid; place-items: center; width: 16%; aspect-ratio: 1; padding: 0; gap: 0; border-radius: 50%; }
.course-cycle--mini .course-cycle__steps li:nth-child(1) { left: 50%; top: 15.33%; }
.course-cycle--mini .course-cycle__steps li:nth-child(2) { left: 80%; top: 32.67%; }
.course-cycle--mini .course-cycle__steps li:nth-child(3) { left: 80%; top: 67.33%; }
.course-cycle--mini .course-cycle__steps li:nth-child(4) { left: 50%; top: 84.67%; }
.course-cycle--mini .course-cycle__steps li:nth-child(5) { left: 20%; top: 67.33%; }
.course-cycle--mini .course-cycle__steps li:nth-child(6) { left: 20%; top: 32.67%; }
.course-cycle--mini .course-cycle__steps .icon { display: block; width: clamp(var(--fs-control), 8cqi, var(--space-xl)); height: clamp(var(--fs-control), 8cqi, var(--space-xl)); }
.course-cycle--mini .course-cycle__core { display: grid; place-items: center; width: 28%; gap: 0; }
.course-cycle--mini .course-cycle__ruby { display: block; width: 100%; height: auto; }

/* The cycle as a score. The stages are the tracks, and the marker line is the person who orchestrates. */
/* The score goes from the left edge of the page content to the right edge of the screen: the work has no end at the right. */
/* --score-left and --score-right are the room between the page content and each edge of the screen. A score inside a container sets the two to 0px. */
/* The line of the orchestrator stands at a part of the page content, and not of the screen, so it keeps its place on a wide screen. */
/* An element above the figure holds the controller and sets --cycle-play-state. */
/* On a stage, the figure takes the roles of the stage. Out of a stage, it takes the ink of a light page. */
.cycle-score {
  --score-left: max(var(--gutter), (100% - var(--container)) / 2);
  --score-right: max(var(--gutter), (100vw - var(--container)) / 2);
  --playhead: calc((100% - var(--score-right)) * .46);
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  column-gap: 1.5rem;
  height: clamp(12.5rem, 33vh, 20.25rem);
  margin: 0;
  padding-left: var(--score-left);
}
.cycle-score__tracks { display: grid; grid-template-rows: calc(var(--score-head) * 1fr) repeat(6, calc(var(--score-pitch) * 1fr)); margin: 0; padding: 0; list-style: none; }
/* The first row is the room of the label of the line. */
.cycle-score__tracks::before { content: ""; }
.cycle-score__tracks li { display: flex; align-items: center; gap: .625rem; color: var(--stage-strong, inherit); font-size: var(--fs-ui-body); font-weight: var(--fw-ui); line-height: 1.1; }
.cycle-score__tracks .icon { color: var(--stage-count, currentColor); }
.cycle-score__sheet { position: relative; min-width: 0; overflow: hidden; }
.cycle-score__defs { position: absolute; }
/* The work that leaves at the left fades beside the names of the tracks. The line and its label stay whole. */
.cycle-score__roll { position: absolute; inset: 0; mask-image: linear-gradient(90deg, transparent, var(--ink) 3rem); }
/* Each layer keeps the scale of the drawing by its height, so a short score has the same proportions. */
.cycle-score__layer { position: absolute; left: 0; top: 0; width: auto; max-width: none; height: 100%; }
.cycle-score__layer--rails { stroke: var(--stage-rule, var(--rail-tie)); stroke-width: 1; }
/* The work that waits is a dashed outline, as a pending note on the site. The work that is done is solid. */
.cycle-score__layer--next { fill: none; stroke: var(--pending); stroke-width: 1.5; stroke-dasharray: 5 4; }
.cycle-score__layer--past { fill: var(--stage-text, var(--ink)); }
/* A wrapper cuts each layer at the line, so a note changes when it crosses the line. */
.cycle-score__side { position: absolute; inset: 0; }
.cycle-score__side--next { clip-path: inset(0 0 0 var(--playhead)); }
.cycle-score__side--past { clip-path: inset(0 calc(100% - var(--playhead)) 0 0); }
.cycle-score__playhead { position: absolute; left: var(--playhead); top: 0; bottom: 0; width: 0; }
.cycle-score__playhead::before { content: ""; position: absolute; left: -1.5px; top: calc(var(--score-head) / var(--score-height) * 50%); bottom: 0; width: 3px; border-radius: 3px; background: var(--stage-signal, var(--ink)); }
.cycle-score__lead { position: absolute; left: 0; top: 0; margin: 0; padding: .25rem .875rem .3125rem; border-radius: var(--radius-pill); background: var(--highlight); color: var(--ink); font-size: var(--fs-control); font-weight: var(--fw-title); line-height: 1.2; white-space: nowrap; translate: -50% 0; }
.cycle-score__hand { position: absolute; left: 0; top: calc((var(--score-head) + var(--score-pitch) * (var(--track) + .5)) / var(--score-height) * 100%); width: .625rem; height: .625rem; border-radius: 50%; background: var(--stage-strong, var(--ink)); box-shadow: 0 0 0 2px var(--stage-bg, var(--bg)); translate: -50% -50%; }

@media (max-width: 900px) {
  .cycle-score { --playhead: calc((100% - var(--score-right)) * .42); column-gap: .75rem; height: 17.5rem; }
  .cycle-score__tracks li { gap: .5rem; font-size: var(--fs-caption); }
}

/* On the narrowest phones, the sheet is not much wider than the label of the line. There, the line stands at the middle of the sheet, so the whole label shows. */
@media (max-width: 359px) {
  .cycle-score { --playhead: calc((100% - var(--score-right)) * .5); }
}

/* The belt moves by one item, and then the same drawing starts again, so the motion has no seam. */
@media (prefers-reduced-motion: no-preference) {
  .cycle-score__belt { animation: cycle-score-belt 4.8s linear infinite; animation-play-state: var(--cycle-play-state, paused); }
}
@keyframes cycle-score-belt { to { transform: translateX(-128px); } }
