/*
 * The pieces of shadcn/ui's AI Elements (https://ui.shadcn.com/docs/components) that the demo page ai-elements.html
 * and the lesson figures share, drawn in the book's tokens: an icon, a status pill, a tool's line and a context
 * readout. elements.mjs draws the icons and the pills; ai-elements.css holds what only the demo page shows.
 * Every colour is a token. An element has no shadow; status is told in words and coloured with `ok`, `warn` or
 * `danger`, and who acted is told by the actor colour of the icon, as the films do.
 */

/* Icons: Lucide drawings, inline or from the demo page's sprite, in the colour of whoever acted. */
.ae-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}
.ae-icon {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  color: var(--muted);
}
.ae-icon.is-tool { color: var(--actor-tool); }
.ae-icon.is-model { color: var(--actor-model); }
.ae-icon.is-runtime { color: var(--actor-runtime); }
.ae-icon.is-session { color: var(--actor-session); }
.ae-icon.is-ok { color: var(--ok); }
.ae-icon.is-run { color: var(--accent); }
.ae-icon.is-warn { color: var(--warn); }
.ae-icon.is-bad { color: var(--danger); }
.ae-icon.is-faint { color: var(--faint); }

/* A line: the icon, what happened, its facts and status, and a chevron when it opens. It is a <summary> when it
   opens and a plain row when it does not; the chevron's column is kept either way, so statuses line up. */
.ae-line {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) auto 16px;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  margin: 0 -8px;
  padding: 6px 8px;
  border-radius: var(--radius);
  color: var(--ink);
}
.ae-line > .ae-icon { grid-area: 1 / 1; }
.ae-line > .ae-title { grid-area: 1 / 2; }
.ae-line > .ae-end { grid-area: 1 / 3; }
.ae-line > .ae-chevron { grid-area: 1 / 4; }
summary.ae-line {
  list-style: none;
}
summary.ae-line::-webkit-details-marker {
  display: none;
}
summary.ae-line:hover {
  background: var(--hover);
}
.ae-title {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  font: 400 var(--text-sm) / 1.4 var(--sans);
}
.ae-title code {
  color: var(--ink);
}
/* A title that is a call alone stays on one line and ends in an ellipsis where it does not fit, as a transcript shows
   it; the whole call stands under it in Parameters. */
.ae-title > code:only-child {
  display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; overflow-wrap: normal;
}
.ae-end {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  white-space: nowrap;
}
.ae-meta {
  font: 400 var(--text-xs) / 1.4 var(--sans);
  color: var(--faint);
}
.ae-chevron {
  color: var(--faint);
  transition: transform 150ms ease-out;
}
details[open] > summary > .ae-chevron {
  transform: rotate(90deg);
}

/* Status: a dot and a word on a pale fill of its colour. A status with no colour of its own is outlined, so it reads
   on a card and on a stage's ground alike. Running's dot pulses only where motion is allowed and the run is live. */
.ae-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 1px 7px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font: 400 var(--text-xs) / 1.35 var(--sans);
  white-space: nowrap;
}
.ae-status[data-tone] { border-color: transparent; }
.ae-status[data-tone="run"] { color: var(--accent-ink); background: var(--accent-pale); }
.ae-status[data-tone="ok"] { color: var(--ok); background: var(--ok-pale); }
.ae-status[data-tone="warn"] { color: var(--warn); background: var(--warn-pale); }
.ae-status[data-tone="bad"] { color: var(--danger); background: var(--danger-pale); }
.ae-dot,
.ae-pulse {
  width: 6px;
  height: 6px;
  flex: none;
  border: 3px solid currentColor;
  border-radius: 50%;
}
.ae-pulse {
  width: 8px;
  height: 8px;
  border-width: 4px;
}
@media (prefers-reduced-motion: no-preference) {
  .ae-pulse {
    animation: ae-pulse 1.4s ease-in-out infinite;
  }
}
@keyframes ae-pulse {
  50% {
    opacity: 0.25;
  }
}

/* Context: how much of a window a request fills, as used / capacity and the share, beside the bar or meter that
   draws it. The numbers keep their width as they change. */
.ae-usage {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  font: 400 var(--text-xs) / 1.4 var(--sans);
  color: var(--muted);
}
.ae-usage-count {
  font-family: var(--mono);
}
.ae-usage-share {
  min-width: 4ch;
  font-weight: 400;
  color: var(--ink);
  text-align: right;
}
.ae-usage.is-warn .ae-usage-share { color: var(--warn); }
.ae-usage.is-over .ae-usage-share { color: var(--danger); }

/* Forced colours draw no fills: a status keeps an edge. */
@media (forced-colors: active) {
  .ae-status {
    border-color: CanvasText;
  }
}

/* A phone: a line's facts go under its title. */
@media (max-width: 640px) {
  .ae-line {
    grid-template-columns: 16px minmax(0, 1fr) 16px;
    row-gap: 4px;
  }
  .ae-line > .ae-end {
    grid-area: 2 / 2;
    justify-content: flex-start;
    flex-wrap: wrap;
  }
  .ae-line > .ae-chevron {
    grid-area: 1 / 3;
  }
}

/* A part's mark standing in a page, not inside another drawing: a tile of its colour, faint, with the glyph at the
   icon set's own stroke in the middle, so a mark reads as an icon and not as a thin line beside a word. */
svg.part-mark:not(svg *) {
  box-sizing: border-box; flex: none; width: 24px; height: 24px; padding: 4px; border-radius: 7px;
  background: color-mix(in srgb, currentColor 14%, transparent); stroke-width: 2;
}
