/* ui/Evolutions — the tree, as a layer over the menu.
   Contract: ./Evolutions.spec.md                                            */

.qc-evo {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  pointer-events: none;
}

/* Decoration, not a scrim: it dims the menu without swallowing clicks, so this
   dialog is honestly aria-modal="false". `data-open` is absent while closed,
   because ui/View drops an attribute whose value is false. */
.qc-evo[data-open]::before {
  content: "";
  position: fixed;
  inset: 0;
  background: color-mix(in oklab, var(--qc-space-0) 58%, transparent);
}

.qc-evo__panel {
  position: relative;
  width: min(880px, calc(100vw - 32px));
  max-height: calc(100dvh - 48px);
  /* The tree scrolls down, never sideways: at 360 px wide it is one column. */
  overflow-x: hidden;
  overflow-y: auto;
  padding: 18px 20px 22px;
  color: var(--qc-text);
  background: var(--qc-glass);
  border: 1px solid var(--qc-line-strong);
  border-radius: var(--qc-radius);
  box-shadow: 0 30px 90px -34px var(--qc-space-0);
  backdrop-filter: blur(14px);
  pointer-events: auto;
}

.qc-evo__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 6px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--qc-line);
}

.qc-evo__title {
  flex: 1 1 auto;
  margin: 0;
  font-size: 1.15rem;
}

.qc-evo__found {
  margin: 0;
  font-variant-numeric: tabular-nums;
  color: var(--qc-text-dim);
}

/* The tree's own reward, under the count it belongs to. Quiet while it is
   still a goal, and in the unlock colour once it is not. */
.qc-evo__reward {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--qc-text-faint);
}

.qc-evo__reward {
  overflow-wrap: anywhere;
}

.qc-evo__reward[data-unlocked="true"],
.qc-evo__reward-item[data-unlocked="true"] {
  color: var(--qc-accent-2);
  font-weight: 600;
}

/* The first-open coach mark on the first tier-I node: a quiet callout with a
   thumb-sized way to put it away. It wraps inside the node on a phone. */
.qc-evo__coach {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  max-width: 100%;
  margin-top: 6px;
  padding: 8px 10px;
  border: 1px dashed var(--qc-accent-2);
  border-radius: 8px;
  background: var(--qc-glass);
}

.qc-evo__coach-text {
  flex: 1 1 12em;
  min-width: 0;
  margin: 0;
  font-size: 13px;
  color: var(--qc-text);
}

.qc-evo__coach-dismiss {
  min-width: 44px;
  min-height: 44px;
  font-size: 13px;
}

/* Why a form is suggested: one quiet line, read after the count. */
.qc-evo__lean {
  flex-basis: 100%;
  order: 1;
  margin: 0;
  font-size: 13px;
  color: var(--qc-text-dim);
}

.qc-evo__close {
  flex: 0 0 auto;
  align-self: flex-start;
}

.qc-evo__lede,
.qc-evo__empty {
  margin: 0 0 18px;
  color: var(--qc-text-dim);
}

.qc-evo__tier {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* A second tier sits inside the branch it grows out of, indented and ruled, so
   the path a pilot took reads as a path rather than as six loose tiles. */
.qc-evo__branch > .qc-evo__tier {
  margin-top: 10px;
  padding-left: 14px;
  border-left: 2px solid var(--qc-line);
}

.qc-evo__node {
  min-width: 0;
  overflow-wrap: anywhere;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--qc-line);
  border-radius: 10px;
  background: var(--qc-glass);
}

/* A tier II form's two apexes, Crest and Halo, side by side under it. */
.qc-evo__tier[data-tier="3"] {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.qc-evo__branch {
  min-width: 0;
}

.qc-evo__node[data-tier="3"] {
  min-height: 56px;
  padding: 10px;
}

/* Which apex a leaf is: a small tag, the same on a ghost as on a found one. */
.qc-evo__kind {
  align-self: center;
  padding: 1px 7px;
  font-family: var(--qc-font-display);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--qc-text-dim);
  border: 1px solid var(--qc-line);
  border-radius: var(--qc-radius-sm);
}

.qc-evo__node[data-kind="halo"] .qc-evo__kind {
  color: var(--qc-accent-2);
}

/* An undiscovered branch is a placeholder, not a card: it takes the room a
   question mark needs and no more, so the tree reads as mostly unfound. */
.qc-evo__node[data-discovered="false"] {
  align-items: center;
  justify-content: center;
  padding: 16px 12px;
  border-style: dashed;
}

.qc-evo__node[data-discovered="true"] {
  border-color: color-mix(in srgb, var(--qc-accent) 60%, var(--qc-line));
  background: color-mix(in srgb, var(--qc-accent) 12%, var(--qc-glass));
  box-shadow: inset 2px 0 0 var(--qc-accent);
}

/* The hull, in the pilot's own paint. A square the parent draws into, sitting
   above the name so the shape is the first thing read. */
.qc-evo__preview {
  display: block;
  width: 84px;
  height: 84px;
  margin: 0 auto 6px;
}

.qc-evo__node[data-discovered="true"] {
  align-items: center;
  text-align: center;
}

.qc-evo__name {
  font-weight: 600;
  color: var(--qc-text);
}

.qc-evo__name--unknown {
  font-size: 1.5rem;
  line-height: 1;
  color: var(--qc-text-dim);
}

.qc-evo__summary {
  font-size: 0.88rem;
  line-height: 1.4;
  color: var(--qc-text-dim);
}

/* An undiscovered form's ghost slot: the parent draws a dim outline, and the
   slot itself stays quieter than a discovered hull. */
.qc-evo__preview[data-ghost="true"] {
  width: 64px;
  height: 64px;
  margin-bottom: 4px;
  opacity: 0.7;
}

/* The form the build leans toward. A hint, not a selection: an accent ring and
   a label, never the discovered card's fill. */
.qc-evo__node[data-suggested="true"] {
  border-color: var(--qc-accent-2);
  box-shadow: 0 0 0 1px var(--qc-accent-2);
  animation: qc-evo-suggest 2.4s var(--qc-ease-out) infinite alternate;
}

.qc-evo__suggested {
  align-self: center;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  color: var(--qc-accent-2);
  border: 1px solid color-mix(in srgb, var(--qc-accent-2) 55%, transparent);
  border-radius: var(--qc-radius-sm);
}

@keyframes qc-evo-suggest {
  from { box-shadow: 0 0 0 1px var(--qc-accent-2); }
  to { box-shadow: 0 0 0 1px var(--qc-accent-2), 0 0 14px -2px var(--qc-accent-2); }
}

/* Phones: one column, a vertical scroll; the apex leaves stack under their
   tier II node, one per row, each a comfortable 56 px target. */
@media (max-width: 599px) {
  .qc-evo {
    padding: 12px 8px;
  }

  .qc-evo__panel {
    width: calc(100vw - 16px);
    max-height: calc(100dvh - 24px);
    padding: 14px 12px 18px;
  }

  .qc-evo__branch > .qc-evo__tier {
    padding-left: 8px;
  }

  .qc-evo__tier[data-tier="3"] {
    grid-template-columns: minmax(0, 1fr);
  }

  .qc-evo__node[data-tier="3"] {
    min-height: 56px;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    text-align: left;
  }

  .qc-evo__node[data-tier="3"] .qc-evo__preview {
    margin: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .qc-evo__node[data-suggested="true"] {
    animation: none;
  }
}
