/*
 * The creation journey: mission bar, quest banner, mission frame, character
 * sheet and the character sprites everywhere else in the app.
 *
 * The look is the project's game prototype: a white theme with a soft lavender
 * ground, the prototype's purple as the journey's accent, rounded cards and
 * pixel-art robots drawn without smoothing.
 */

/* ------------------------------- characters ------------------------------ */

/*
 * One frame of a sprite sheet: the sheet is twelve frames wide, so it is sized
 * to twelve times the element and slid along by background-position
 * (ui/character-sprite.js). Pixel art, so never smoothed.
 */
.character {
  display: inline-block;
  flex: none;
  vertical-align: middle;
  background-repeat: no-repeat;
  background-size: 1200% 100%;
  image-rendering: pixelated;
}

/*
 * The idle breath. The resting pose is the base rule, untransformed, so the
 * global reduced-motion rule (base.css) leaves a character standing still and
 * whole rather than frozen mid-air.
 */
.character--bob {
  transform-origin: 50% 100%;
  animation: character-bob 2.6s ease-in-out infinite;
}

@keyframes character-bob {
  0%,
  100% {
    transform: translateY(0) scale(1, 1);
  }

  50% {
    transform: translateY(-4px) scale(0.99, 1.01);
  }
}

/* An agent's face on cards: its emoji on a soft disc (ui/avatar-art.js). */
.avatar-art {
  display: inline-grid;
  flex: none;
  place-items: center;
  border-radius: var(--radius-pill);
  background: radial-gradient(circle at 50% 35%, #ffffff, var(--journey-accent-soft) 70%);
  line-height: 1;
  user-select: none;
}

/* ------------------------------- the frame ------------------------------- */

.builder__content > .quest-banner,
.builder__step {
  max-width: var(--content-max);
  margin-inline: auto;
}

/* ------------------------------ mission rail ----------------------------- */

.mission-rail {
  align-self: start;
  margin: var(--space-6) 0 0 var(--space-6);
  padding: 8px;
  border: 1px solid var(--journey-accent-line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 6px 20px rgba(76, 52, 160, 0.06);
}

.mission-rail__list {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.mission-rail__button {
  position: relative;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1.5px solid transparent;
  border-radius: 14px;
  background: var(--journey-accent-soft);
  color: var(--journey-accent);
  transition:
    background var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out),
    transform var(--duration-fast) var(--ease-out);
}

.mission-rail__button:hover {
  border-color: var(--journey-accent-line);
  transform: translateY(-1px);
}

.mission-rail__button[aria-current='step'] {
  border-color: var(--journey-accent);
  background: var(--journey-accent);
  color: #fff;
  box-shadow: 0 6px 16px rgba(116, 55, 239, 0.32);
}

/* How much of the mission is done, as a thin bar along the bottom edge. */
.mission-rail__progress {
  position: absolute;
  left: 9px;
  right: 9px;
  bottom: 6px;
  height: 3px;
  border-radius: var(--radius-pill);
  background: rgba(116, 55, 239, 0.16);
  overflow: hidden;
}

.mission-rail__fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--journey-accent);
  transition: width var(--duration-base) var(--ease-out);
}

.mission-rail__button[aria-current='step'] .mission-rail__progress {
  background: rgba(255, 255, 255, 0.3);
}

.mission-rail__button[aria-current='step'] .mission-rail__fill {
  background: #fff;
}

.mission-rail__badge {
  position: absolute;
  top: -4px;
  right: -4px;
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border: 2px solid var(--surface);
  border-radius: var(--radius-pill);
  background: var(--journey-done);
  color: #fff;
}

.mission-rail__badge[hidden] {
  display: none;
}

.mission-rail__divider {
  width: 24px;
  height: 1px;
  background: var(--journey-accent-line);
}

.mission-rail__button--finale {
  background: var(--surface);
  border-color: var(--journey-accent-line);
}

/* ------------------------------ quest banner ----------------------------- */

.quest-banner {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: var(--space-4);
  min-height: 188px;
  padding: var(--space-4) var(--space-6) 0;
  border: 1px solid #dbe3fb;
  border-radius: 18px;
  overflow: hidden;
  background: url('../assets/scenery/quest-landscape.png') right bottom / cover no-repeat, #c6d4fb;
  image-rendering: pixelated;
}

.quest-banner__hero {
  flex: none;
  margin-bottom: -2px;
}

.quest-banner__flag {
  position: absolute;
  left: 152px;
  bottom: 40px;
  width: 3px;
  height: 72px;
  background: #4b3f7a;
}

.quest-banner__flag::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 2px;
  border-left: 26px solid var(--journey-accent);
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
}

.quest-banner__speech {
  position: relative;
  align-self: center;
  max-width: 470px;
  margin-bottom: var(--space-4);
  padding: 14px 18px;
  border: 2px solid var(--journey-accent-line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 8px 24px rgba(52, 38, 125, 0.12);
  image-rendering: auto;
}

.quest-banner__speech::before {
  content: '';
  position: absolute;
  left: -11px;
  top: 50%;
  width: 18px;
  height: 18px;
  border-left: 2px solid var(--journey-accent-line);
  border-bottom: 2px solid var(--journey-accent-line);
  background: inherit;
  transform: translateY(-50%) rotate(45deg);
}

.quest-banner__title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.quest-banner__text {
  margin-top: 4px;
  font-size: 14px;
  line-height: var(--leading-relaxed);
  color: var(--text-secondary);
}

/* ----------------------------- mission frame ----------------------------- */

.builder__step .step-view {
  max-width: none;
  margin-top: var(--space-6);
}

.step-view__eyebrow {
  color: var(--journey-accent);
}

.step-view__dots {
  display: flex;
  align-items: center;
  gap: 6px;
}

.step-view__dot {
  width: 7px;
  height: 7px;
  border-radius: var(--radius-pill);
  background: #dcd5f1;
  transition: width var(--duration-base) var(--ease-out);
}

.step-view__dot[data-active='true'] {
  width: 20px;
  background: var(--journey-accent);
}

/* --------------------------------- sheet --------------------------------- */

.sheet {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sheet__card {
  padding: 14px;
  border: 1px solid #ebe7f7;
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 6px 20px rgba(76, 52, 160, 0.06);
}

.sheet__top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

/* Minimal icon buttons beside the face: Markdown, save, import. */
.quick-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.quick-action {
  position: relative;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1px solid var(--journey-accent-line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--journey-accent-deep);
  transition:
    background var(--duration-fast) var(--ease-out),
    transform var(--duration-fast) var(--ease-out);
}

.quick-action:hover {
  background: var(--journey-accent-soft);
  transform: translateY(-1px);
}

/* The autosave state, on the save button. */
.quick-action__dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  border: 2px solid var(--surface);
  border-radius: var(--radius-pill);
  background: var(--border-strong);
}

.quick-action__dot[data-status='saved'] {
  background: var(--journey-done);
}

.quick-action__dot[data-status='saving'] {
  background: var(--accent-warm);
}

.quick-action__dot[data-status='error'] {
  background: var(--danger);
}

.sheet__stage {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 176px;
  border-radius: 14px;
  overflow: hidden;
  background: radial-gradient(circle at 50% 38%, #ffffff 0, #e9e0ff 52%, #cbb6ff 100%);
}

/*
 * The agent's face, big, floating over the platform. The float is CSS, so the
 * global reduced-motion rule leaves it resting in place.
 */
.sheet__emoji {
  position: relative;
  z-index: 2;
  margin-top: -14px;
  font-size: 104px;
  line-height: 1;
  filter: drop-shadow(0 10px 12px rgba(52, 38, 125, 0.22));
  user-select: none;
  animation: emoji-float 3.2s ease-in-out infinite;
}

@keyframes emoji-float {
  0%,
  100% {
    transform: translateY(0) rotate(-3deg);
  }

  50% {
    transform: translateY(-10px) rotate(3deg);
  }
}

/* A new roll pops in, then goes back to floating. */
.sheet__emoji--pop {
  animation:
    emoji-pop 420ms cubic-bezier(0.2, 0.9, 0.3, 1.4),
    emoji-float 3.2s ease-in-out 420ms infinite;
}

@keyframes emoji-pop {
  from {
    transform: scale(0.3) rotate(-25deg);
  }

  to {
    transform: scale(1) rotate(-3deg);
  }
}

.sheet__dice {
  position: absolute;
  right: 8px;
  bottom: 8px;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--journey-accent-line);
  border-radius: 12px;
  background: var(--surface);
  font-size: 20px;
  line-height: 1;
  box-shadow: 0 4px 12px rgba(52, 38, 125, 0.16);
  transition: transform var(--duration-fast) var(--ease-out);
}

.sheet__dice:hover {
  transform: rotate(-12deg) scale(1.06);
}

.sheet__dice:active {
  transform: rotate(20deg) scale(0.94);
}

.sheet__orb {
  position: absolute;
  left: 50%;
  top: 40%;
  width: 124px;
  height: 124px;
  border-radius: var(--radius-pill);
  background: radial-gradient(circle, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0) 70%);
  transform: translate(-50%, -50%);
}

.sheet__platform {
  position: absolute;
  bottom: 10px;
  left: 50%;
  width: 128px;
  height: 22px;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(116, 55, 239, 0.55) 0%, rgba(116, 55, 239, 0.2) 55%, rgba(116, 55, 239, 0) 72%);
  transform: translateX(-50%);
}

.sheet__glint {
  position: absolute;
  z-index: 1;
  color: #fff;
  font-size: 14px;
  text-shadow: 0 0 6px rgba(116, 55, 239, 0.5);
  opacity: 0.85;
  animation: sheet-glint 2.8s ease-in-out infinite;
}

.sheet__glint--1 {
  top: 14px;
  left: 16px;
}

.sheet__glint--2 {
  top: 40px;
  right: 18px;
  animation-delay: -0.9s;
}

.sheet__glint--3 {
  bottom: 50px;
  right: 24px;
  animation-delay: -1.8s;
}

@keyframes sheet-glint {
  0%,
  100% {
    opacity: 0.25;
    transform: scale(0.8);
  }

  50% {
    opacity: 1;
    transform: scale(1.1);
  }
}

/* What the character says about itself. */
.sheet__bubble {
  position: relative;
  margin-top: 14px;
  padding: 10px 12px;
  border: 1.5px solid var(--journey-accent-line);
  border-radius: 14px;
  background: var(--surface);
  font-size: 13px;
  line-height: 1.5;
}

.sheet__bubble::before {
  content: '';
  position: absolute;
  top: -8px;
  left: 76px;
  width: 14px;
  height: 14px;
  border-left: 1.5px solid var(--journey-accent-line);
  border-top: 1.5px solid var(--journey-accent-line);
  background: var(--surface);
  transform: rotate(45deg);
}

/* The AGENT.md dialog (ui/markdown-dialog.js). */
.markdown-dialog .scroll__body {
  max-height: min(60vh, 560px);
  margin-top: var(--space-4);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
}


/* The tools line of the summary: the icons, and every tool on hover or focus. */
.tool-icons {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.tool-icon {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: var(--journey-accent-soft);
  color: var(--journey-accent-deep);
  font-size: 11px;
  font-weight: 700;
}

.tools-wrap {
  position: relative;
  display: inline-block;
  border-radius: 8px;
  cursor: default;
}

/*
 * A card floating over the page (ui/floating.js): in the top layer, placed in
 * viewport coordinates by script, so nothing around its trigger clips it.
 * The popover defaults (centred, framed, Canvas colours) are undone here.
 */
.float-card {
  position: fixed;
  inset: auto;
  z-index: 60;
  margin: 0;
  padding: 10px;
  overflow: visible;
  border: 1px solid var(--journey-accent-line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text-primary);
  box-shadow: 0 12px 30px rgba(52, 38, 125, 0.18);
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  transition:
    opacity var(--duration-fast) var(--ease-out),
    transform var(--duration-fast) var(--ease-out);
}

.float-card.is-open {
  opacity: 1;
  visibility: visible;
  transform: none;
}

@starting-style {
  .float-card.is-open {
    opacity: 0;
    transform: translateY(4px);
  }
}

/* Under the mouse it only shows; the mouse never has to reach it. */
.float-card--pointer {
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .float-card {
    transform: none;
    transition: none;
  }
}

.tools-pop {
  width: 270px;
}

.tools-pop__list {
  display: grid;
  gap: 6px;
  max-height: 240px;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.tools-pop__item {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.tools-pop__icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--journey-accent-soft);
  color: var(--journey-accent);
}

.tools-pop__name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tools-pop__permission {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.tools-pop__empty {
  font-size: 13px;
  color: var(--text-secondary);
}

/* -------------------------------- summary -------------------------------- */

.sheet__heading {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  font-size: 14px;
  font-weight: 800;
}

.summary {
  display: grid;
  margin: 0;
}

.summary__row {
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 7px 0;
  border-top: 1px solid var(--border-subtle);
  font-size: 13px;
}

.summary__row:first-child {
  border-top: none;
}

.summary__label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.summary__icon {
  display: inline-flex;
  flex: none;
  color: var(--journey-accent);
}

.summary__empty {
  color: var(--text-secondary);
}

.summary__value,
.summary__action {
  margin: 0;
}

.summary__value {
  color: var(--text-secondary);
  overflow-wrap: anywhere;
}

/* The company's logo, small, on the left of the model's name. */
.summary__model {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.summary__model .vendor-logo {
  border-radius: 6px;
  box-shadow: none;
}

.summary__model .vendor-badge {
  border-radius: 6px;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
}

.icon-btn:hover {
  background: var(--surface-muted);
  color: var(--text-primary);
}

/* --------------------------------- tools --------------------------------- */

/* What the agent carries right now, above the catalogue. */
.loadout {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  margin-bottom: var(--space-4);
  padding: 10px 12px;
  border: 1px dashed var(--journey-accent-line);
  border-radius: 14px;
  background: #fbfaff;
}

.loadout__label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--journey-accent);
}

.loadout__empty {
  font-size: 13px;
  color: var(--text-secondary);
}

.loadout__list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.loadout__chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--journey-accent-line);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--journey-accent-deep);
  font-size: 13px;
  font-weight: 600;
  transition: transform var(--duration-fast) var(--ease-out);
}

.loadout__chip:hover {
  transform: translateY(-1px);
}

/* One card of the catalogue: the whole card is the switch. */
.tool-tile-wrap {
  position: relative;
  display: flex;
}

.tool-tile {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  padding: 12px;
  border: 1.5px solid var(--border-subtle);
  border-radius: 14px;
  background: var(--surface);
  text-align: left;
  transition:
    border-color var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out),
    transform var(--duration-fast) var(--ease-out);
}

.tool-tile:hover {
  border-color: var(--journey-accent-line);
  transform: translateY(-1px);
}

.tool-tile[aria-checked='true'] {
  border-color: var(--journey-accent);
  background: #fbfaff;
  box-shadow: 0 0 0 3px var(--journey-accent-soft);
}

.tool-tile__icon {
  display: grid;
  flex: none;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--journey-accent-soft);
  color: var(--journey-accent);
}

.tool-tile[aria-checked='true'] .tool-tile__icon {
  background: var(--journey-accent);
  color: #fff;
}

.tool-tile__text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding-right: 18px;
}

.tool-tile__name {
  font-weight: 700;
}

.tool-tile__description {
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-secondary);
}

.tool-tile__examples {
  margin-top: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--journey-accent-deep);
}

.tool-tile__state {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-pill);
  color: var(--text-secondary);
}

.tool-tile[aria-checked='true'] .tool-tile__state {
  border-color: var(--journey-accent);
  background: var(--journey-accent);
  color: #fff;
}

.tool-tile-wrap--custom .tool-tile__text {
  padding-right: 44px;
}

.tool-tile__remove {
  position: absolute;
  right: 36px;
  top: 8px;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
}

.tool-tile__remove:hover {
  background: var(--danger-soft, #fdecec);
  color: var(--danger);
}

/* The configuration of the equipped tools. */
.tool-rows {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tool-cell {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--journey-accent-line);
  border-radius: 14px;
  background: var(--surface);
}

.tool-cell:focus-visible {
  outline: 2px solid var(--journey-accent);
  outline-offset: 2px;
}

.tool-row__head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tool-row__head .tool-tile__icon {
  width: 32px;
  height: 32px;
  background: var(--journey-accent);
  color: #fff;
}

.tool-row__name {
  flex: 1;
  font-weight: 700;
}

.tool-row__fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
}

.tool-row__field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.tool-row__permission .helper {
  margin-top: 4px;
  max-width: 330px;
}

/* Three options, one control: the permission of a tool. */
.segmented {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  background: var(--surface-secondary);
}

.segmented__option {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border-radius: 9px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.segmented__option:hover {
  color: var(--text-primary);
}

.segmented__option[aria-checked='true'] {
  background: var(--surface);
  color: var(--journey-accent-deep);
  box-shadow: 0 1px 3px rgba(52, 38, 125, 0.16);
}

@media (max-width: 860px) {
  .tool-row__fields {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ------------------------------- text lists ------------------------------ */

.text-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0 0 var(--space-3);
  padding: 0;
  list-style: none;
}

.text-list:empty {
  display: none;
}

.text-list__item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 6px 6px 10px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.text-list__icon,
.text-list__number {
  display: grid;
  flex: none;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 8px;
  background: var(--journey-accent-soft);
  color: var(--journey-accent);
  font-size: 12px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.text-list__text {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.icon-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.icon-btn:disabled:hover {
  background: none;
  color: var(--text-secondary);
}

/* ------------------------------- flow editor ------------------------------ */

/* A dotted canvas, like a node editor's, holding one column of blocks. */
.flow {
  --flow-line: #cfc6ef;
  padding: 18px 14px;
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  background-color: #fbfaff;
  background-image: radial-gradient(circle, #ddd6f3 1px, transparent 1.2px);
  background-size: 16px 16px;
}

.flow__list {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0;
  padding: 0;
  list-style: none;
}

.flow__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

/* The joint between two blocks: a line through a round "+". */
.flow__joint {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  padding: 6px 0;
}

.flow__joint::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  background: var(--flow-line);
  transform: translateX(-50%);
}

.flow__item:first-child .flow__joint::before {
  top: 50%;
}

.flow__item--end .flow__joint::before {
  bottom: 50%;
}

.flow__joint--start::before {
  display: none;
}

.flow__add {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 1.5px solid var(--flow-line);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--journey-accent);
  transition:
    transform var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out);
}

.flow__add:hover,
.flow__add[aria-expanded='true'] {
  border-color: var(--journey-accent);
  transform: scale(1.12);
}

.flow__add--start {
  display: inline-flex;
  gap: 6px;
  width: auto;
  height: auto;
  padding: 8px 14px;
  border-style: dashed;
  font-weight: 700;
}

.flow__add--start:hover {
  transform: translateY(-1px);
}

.flow__empty {
  text-align: center;
}

.flow__empty-title {
  font-weight: 700;
}

/* The picker of block types, opened from a "+". */
.flow-picker {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  width: min(520px, 100%);
  margin-top: 8px;
  padding: 8px;
  border: 1px solid var(--journey-accent-line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 12px 30px rgba(52, 38, 125, 0.16);
}

.flow-picker__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 10px;
  text-align: left;
}

.flow-picker__item:hover {
  background: var(--journey-accent-soft);
}

.flow-picker__text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.flow-picker__label {
  font-size: 13px;
  font-weight: 700;
}

.flow-picker__description {
  font-size: 12px;
  color: var(--text-secondary);
}

/* A block. */
.flow-node {
  --node: var(--journey-accent);
  width: min(520px, 100%);
  border: 1.5px solid var(--border-subtle);
  border-left: 4px solid var(--node);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 2px 8px rgba(52, 38, 125, 0.06);
}

.flow-node[data-open='true'] {
  border-color: var(--node);
  box-shadow: 0 0 0 3px var(--journey-accent-soft);
}

.flow-node[data-type='trigger'],
.flow-picker__item[data-type='trigger'] {
  --node: #ed9452;
}

.flow-node[data-type='tool'],
.flow-picker__item[data-type='tool'] {
  --node: #487ef2;
}

.flow-node[data-type='condition'],
.flow-picker__item[data-type='condition'] {
  --node: #c04dff;
}

.flow-node[data-type='approval'],
.flow-picker__item[data-type='approval'] {
  --node: #159c99;
}

.flow-node[data-type='memory'],
.flow-picker__item[data-type='memory'] {
  --node: #f36e9a;
}

.flow-node[data-type='output'],
.flow-picker__item[data-type='output'] {
  --node: var(--journey-done);
}

.flow-node__head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 8px 10px 10px;
}

.flow-node__icon {
  display: grid;
  flex: none;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  /* --node comes from the block or the picker item it sits in. */
  background: color-mix(in srgb, var(--node, var(--journey-accent)) 14%, white);
  color: var(--node, var(--journey-accent));
}

.flow-node__text {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.flow-node__kind {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--node);
}

.flow-node__tool {
  color: var(--text-secondary);
  text-transform: none;
  letter-spacing: 0;
}

.flow-node__title {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.flow-node__detail {
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.flow-node__actions {
  display: flex;
  flex: none;
  gap: 2px;
}

.flow-node__editor {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 12px 12px;
}

.flow-node__editor .chip-row {
  margin-bottom: 4px;
}

.flow-node__editor-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
}

@media (max-width: 640px) {
  .flow-picker {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ------------------------------ model picker ----------------------------- */

.model-picker__label {
  margin: 14px 0 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--journey-accent);
}

.model-picker__label:first-child {
  margin-top: 0;
}

.vendor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}

.vendor-card {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 72px;
  padding: 12px 14px;
  border: 1.5px solid var(--border-subtle);
  border-radius: 14px;
  background: var(--surface);
  font-weight: 600;
  text-align: left;
  transition: border-color var(--duration-fast) var(--ease-out);
}

.vendor-card:hover {
  border-color: var(--journey-accent-line);
}

.vendor-card[aria-checked='true'] {
  border-color: var(--journey-accent);
  background: #fbfaff;
  box-shadow: 0 0 0 3px var(--journey-accent-soft);
}

.vendor-logo {
  display: inline-grid;
  flex: none;
  place-items: center;
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 2px 6px rgba(16, 16, 16, 0.06);
}

.vendor-card__text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.vendor-card__name {
  font-size: 15px;
  font-weight: 700;
}

.vendor-card__count {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.vendor-badge {
  display: inline-grid;
  flex: none;
  place-items: center;
  border-radius: 10px;
  color: #fff;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
}

.model-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
}

.model-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border: 1.5px solid var(--border-subtle);
  border-radius: 14px;
  background: var(--surface);
  text-align: left;
}

.model-card[aria-checked='true'] {
  border-color: var(--journey-accent);
  background: #fbfaff;
  box-shadow: 0 0 0 3px var(--journey-accent-soft);
}

.model-card__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding-right: 22px;
}

.model-card__name {
  font-weight: 700;
}

.model-card__pick {
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  background: #fff6de;
  color: #7a4f00;
  font-size: 11px;
  font-weight: 700;
}

.model-card__use {
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-secondary);
}

.model-card__level {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding-top: 6px;
}

.model-card__level-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.level-bar {
  display: inline-flex;
  gap: 3px;
}

.level-bar__segment {
  width: 18px;
  height: 6px;
  border-radius: var(--radius-pill);
  background: #e6e2f3;
}

.level-bar__segment[data-on='true'] {
  background: linear-gradient(90deg, var(--journey-accent), #b06cff);
}

.model-card__check {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: var(--radius-pill);
  background: var(--journey-accent);
  color: #fff;
  opacity: 0;
}

.model-card[aria-checked='true'] .model-card__check {
  opacity: 1;
}

.vendor-logo--none {
  border-style: dashed;
  box-shadow: none;
  color: var(--text-secondary);
}

/* -------------------------------- confetti ------------------------------- */

.confetti {
  position: fixed;
  inset: 0;
  z-index: 1000;
  overflow: hidden;
  pointer-events: none;
}

/* Removed from the DOM after two seconds (ui/celebrate.js); never built under
   reduced motion. */
.confetti__piece {
  position: absolute;
  top: -14px;
  width: 8px;
  height: 12px;
  border-radius: 2px;
  animation: confetti-fall 1.2s ease-in forwards;
}

@keyframes confetti-fall {
  to {
    transform: translateY(105vh) rotate(540deg);
  }
}

/* ------------------------------- menu motion ------------------------------ */

/*
 * Light motion on the menus that start the game: the home actions, the "how do
 * you want to start" choices, the mission rail and the sheet's quick actions.
 * Hovers lift and nudge their icon; the rail and the choices arrive one item at
 * a time. All of it is transform-only CSS with no fill-mode, so the resting
 * state is the base rule, nothing is ever hidden, and the global reduced-motion
 * rule (base.css) stills every bit of it.
 */
@keyframes menu-rise {
  from {
    transform: translateY(8px) scale(0.96);
  }
}

@keyframes icon-nudge {
  0%,
  100% {
    transform: rotate(0deg);
  }

  30% {
    transform: rotate(-12deg) scale(1.12);
  }

  60% {
    transform: rotate(8deg) scale(1.06);
  }
}

@keyframes icon-bob {
  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-2px);
  }
}

.hero__actions .btn,
.hero__actions-row .btn {
  transition:
    transform var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out);
}

.hero__actions .btn:hover,
.hero__actions-row .btn:hover {
  transform: translateY(-2px);
}

.hero__actions .btn-primary:hover {
  box-shadow: 0 10px 24px rgba(193, 53, 132, 0.28);
}

.hero__actions .btn:hover .icon,
.hero__actions-row .btn:hover .icon,
.choice-card:hover .choice-card__icon .icon,
.quick-action:hover .icon,
.mission-rail__button:hover .icon {
  animation: icon-nudge 520ms var(--ease-out);
}

.choice-list > * {
  animation: menu-rise 360ms var(--ease-out);
}

.choice-list > *:nth-child(2) {
  animation-delay: 60ms;
}

.choice-list > *:nth-child(3) {
  animation-delay: 120ms;
}

.mission-rail__list > li {
  animation: menu-rise 320ms var(--ease-out);
}

.mission-rail__list > li:nth-child(2) {
  animation-delay: 40ms;
}

.mission-rail__list > li:nth-child(3) {
  animation-delay: 80ms;
}

.mission-rail__list > li:nth-child(4) {
  animation-delay: 120ms;
}

.mission-rail__list > li:nth-child(5) {
  animation-delay: 160ms;
}

.mission-rail__list > li:nth-child(n + 6) {
  animation-delay: 200ms;
}

/* The mission on screen breathes a little, so the rail says where you are. */
.mission-rail__button[aria-current='step'] .icon {
  animation: icon-bob 1.8s ease-in-out infinite;
}

.mission-rail__button[aria-current='step']:hover .icon {
  animation: icon-nudge 520ms var(--ease-out);
}

/* ------------------------------- responsive ------------------------------ */

/* Below 1024px the rail lies down into a row of icons above the mission. */
@media (max-width: 1023px) {
  .mission-rail {
    justify-self: center;
    margin: var(--space-3) var(--space-4) 0;
    padding: 6px;
  }

  .mission-rail__list {
    flex-direction: row;
    gap: 6px;
  }

  .mission-rail__button {
    width: 42px;
    height: 42px;
  }

  .mission-rail__divider {
    width: 1px;
    height: 24px;
  }
}

@media (max-width: 640px) {
  .quest-banner {
    min-height: 0;
    padding: var(--space-3) var(--space-3) 0;
  }

  .quest-banner__flag {
    display: none;
  }

  /* Back and the way on are what matter here; the dots repeat the rail. */
  .step-view__dots {
    display: none;
  }

  /* The sprite's size is inline, so only !important reaches it here. */
  .quest-banner .character {
    width: 84px !important;
    height: 84px !important;
  }

  .quest-banner__title {
    font-size: 16px;
  }

  .quest-banner__text {
    font-size: 13px;
  }

  .sheet__top {
    grid-template-columns: minmax(0, 1fr);
  }

}

/* ------------------------- hint and profile dialog ------------------------ */

/* "Precisa de um ponto de partida?", on the first screen (steps/identity.js). */
.hint-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid #f3dd8c;
  border-radius: 999px;
  background: #fff8dc;
  color: #7a5a00;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  transition:
    background var(--duration-fast) var(--ease-out),
    transform var(--duration-fast) var(--ease-out);
}

.hint-button:hover {
  background: #ffefb0;
  transform: translateY(-1px);
}

.hint-button .icon {
  color: #c48a00;
}

.profile-dialog__warning {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--text-secondary);
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
}

.profile-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  height: 100%;
  padding: 12px;
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  background: var(--surface);
  text-align: left;
  transition:
    border-color var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out),
    transform var(--duration-fast) var(--ease-out);
}

.profile-card:hover {
  border-color: var(--journey-accent);
  box-shadow: 0 6px 18px rgba(52, 38, 125, 0.12);
  transform: translateY(-1px);
}

.profile-card[aria-pressed='true'] {
  border-color: var(--journey-accent);
  box-shadow: 0 0 0 3px var(--journey-accent-soft);
}

.profile-card__icon {
  display: grid;
  flex: none;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--journey-accent-soft);
  color: var(--journey-accent);
}

.profile-card__text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.profile-card__label {
  font-weight: 800;
  font-size: 14px;
}

.profile-card__example {
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text-secondary);
}

@media (prefers-reduced-motion: reduce) {
  .hint-button,
  .profile-card {
    transition: none;
  }

  .hint-button:hover,
  .profile-card:hover {
    transform: none;
  }
}

/* ------------------------------ the finale ------------------------------- */

/* The tool the single file goes to (steps/export.js), on the brain's cards. */
.target-card__badge {
  width: 40px;
  height: 40px;
  font-size: 14px;
}

.target-card__path {
  font-family: var(--font-mono);
  font-size: 11.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.target-file__where {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.target-file__where .helper {
  margin: 0;
}

.target-file__path {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--journey-accent-deep);
}

.target-file__path code {
  padding: 3px 8px;
  border-radius: 8px;
  background: var(--journey-accent-soft);
  font-family: var(--font-mono);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.target-file__limit {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid #f3dd8c;
  border-radius: 12px;
  background: #fff8dc;
  color: #7a5a00;
  font-size: 13px;
}

.target-file__preview {
  max-height: 420px;
  margin: 0 0 16px;
  padding: 14px 16px;
  overflow: auto;
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  background: #faf9fe;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.target-file__preview:focus-visible {
  outline: 2px solid var(--journey-accent);
  outline-offset: 2px;
}

/* --------------------------- the model numbers --------------------------- */

/* Above the mouse on a model card (components/model-picker.js). */
.model-stats {
  width: 330px;
  max-width: calc(100vw - 16px);
  padding: 14px;
  font-size: 12.5px;
}

.model-stats__head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.model-stats__head .vendor-logo,
.model-stats__head .vendor-badge {
  border-radius: 8px;
  box-shadow: none;
}

.model-stats__title {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.model-stats__title strong {
  font-size: 14px;
  font-weight: 800;
}

.model-stats__title span {
  color: var(--text-secondary);
  font-size: 11.5px;
}

.model-stats__level .level-bar__segment {
  width: 10px;
  height: 5px;
}

.model-stats__price {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 10px 0 8px;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--journey-accent-soft);
}

.model-stats__price-label {
  display: flex;
  flex-direction: column;
  color: var(--journey-accent-deep);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.model-stats__price-label small {
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
}

.model-stats__price strong {
  color: var(--journey-accent-deep);
  font-size: 19px;
  font-weight: 800;
  white-space: nowrap;
}

.model-stats__price strong.is-empty {
  color: var(--text-secondary);
  font-size: 13px;
  font-style: italic;
  font-weight: 600;
}

.model-stats__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin: 0;
}

.model-stats__tile {
  padding: 6px 8px;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
}

.model-stats__tile dt {
  color: var(--text-secondary);
  font-size: 10.5px;
}

.model-stats__tile dd {
  margin: 0;
  font-size: 12.5px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.model-stats__tile dd.is-empty {
  color: var(--text-secondary);
  font-style: italic;
  font-weight: 500;
}

.model-stats__task {
  margin: 8px 0 0;
  color: var(--text-secondary);
  font-size: 11.5px;
}

.model-stats__task strong {
  color: var(--text-primary);
}

.model-stats__note {
  margin: 6px 0 0;
  padding: 7px 10px;
  border-radius: 10px;
  background: #fff8dc;
  color: #7a5a00;
  font-size: 11.5px;
}

.model-stats__source {
  margin: 8px 0 0;
  color: var(--text-secondary);
  font-size: 10.5px;
  overflow-wrap: anywhere;
}

.model-picker__hint {
  margin-top: -4px;
  font-size: 12px;
}
