/* The Goals App demo: a chat, the trip a message takes, and today's chart.
   Black and white like the rest of the site. Everything is scoped to .goals-demo. */

.goals-demo {
  --panel: #0e1114;      /* a shade off the frame, for the chat and data boxes */
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, .75fr) minmax(0, 1.15fr);
  gap: 28px;
  padding: 28px;
  background: var(--paper);
  line-height: 1.45;
}

.goals-demo button { font-family: inherit; cursor: pointer; }  /* sizes are set per button below */

/* --- The chat --- */

.gd-chat { display: flex; flex-direction: column; min-width: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); overflow: hidden; }
.gd-chat-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); font-size: 15px; font-weight: 600; }
.gd-avatar { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--ink); color: var(--paper); font-size: 14px; }

/* Fixed height, so a long chat scrolls inside the box and the page doesn't grow. */
.gd-messages { display: flex; flex-direction: column; gap: 8px; height: 300px; padding: 14px; overflow-y: auto; overscroll-behavior: contain; }
.gd-bubble { max-width: 85%; padding: 8px 12px; border-radius: 14px; font-size: 15px; }
.gd-bubble.from-me { align-self: flex-end; background: var(--ink); color: var(--paper); border-bottom-right-radius: 4px; }
.gd-bubble.from-bot { align-self: flex-start; border: 1px solid var(--line); background: #161a1f; border-bottom-left-radius: 4px; }

/* Three dots that rise in turn while the bot "thinks". */
.gd-typing { display: flex; gap: 4px; padding: 12px 14px; }
.gd-typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--soft); animation: gd-dot 1s infinite ease-in-out; }
.gd-typing span:nth-child(2) { animation-delay: .15s; }
.gd-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes gd-dot { 0%, 60%, 100% { transform: none; opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }

.gd-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 14px 14px; border-top: 1px solid var(--line); }
.gd-chip { padding: 7px 12px; border: 1px solid var(--soft); border-radius: 999px; background: transparent; color: var(--ink); font-size: 14px; transition: background .15s, color .15s, border-color .15s; }
/* Hover only with a real mouse: on a touchscreen it sticks to the chip that lands under the finger. */
@media (hover: hover) {
  .gd-chip:hover:not(:disabled) { background: var(--ink); color: var(--paper); border-color: var(--ink); }
}
.gd-chip:disabled { cursor: default; opacity: .4; }
.gd-chip.is-sent { background: var(--ink); color: var(--paper); border-color: var(--ink); opacity: 1; }

/* --- The trip: four steps top to bottom, joined by a line that fills as the message passes --- */

.gd-flow { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.gd-steps { display: flex; flex-direction: column; gap: 22px; padding: 0; list-style: none; }
.gd-steps li { position: relative; padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; color: var(--soft); transition: border-color .2s, color .2s, background .2s; }
.gd-steps b { display: block; font-size: 15px; font-weight: 600; }
.gd-steps span { display: block; font-size: 13px; }
/* The joining line between a step and the one above it. ::after is its filled part. */
.gd-steps li + li::before,
.gd-steps li + li::after { content: ""; position: absolute; left: 50%; bottom: 100%; width: 1px; height: 23px; background: var(--line); }
.gd-steps li + li::after { background: var(--ink); transform: scaleY(0); transform-origin: top; transition: transform .3s ease; }
.gd-steps li.is-active { border-color: var(--ink); color: var(--ink); background: #161a1f; }
.gd-steps li.is-passed { border-color: var(--soft); color: var(--ink); }
.gd-steps li.is-active::after,
.gd-steps li.is-passed::after { transform: none; }

/* What the model made of the message. */
.gd-data { min-height: 96px; margin: 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--soft); font: 13px/1.5 ui-monospace, "Cascadia Mono", Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; transition: color .3s; }
.gd-data.is-filled { color: var(--ink); }

/* --- Today's chart --- */

.gd-today { display: flex; align-items: center; min-width: 0; }
.goals-chart { width: 100%; margin: 0; text-align: center; }
.goals-chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.goals-chart figcaption { margin-top: 6px; color: var(--soft); font-size: 15px; }

.radar-grid { fill: none; stroke: var(--line); stroke-width: 1.5; }
.radar-target { fill: none; stroke: var(--soft); stroke-width: 1.5; stroke-dasharray: 5 6; }
.radar-spoke { stroke: var(--line); stroke-width: 1.5; }
.radar-shape { fill: var(--ink); fill-opacity: .12; stroke: var(--ink); stroke-width: 3; stroke-linejoin: round; transition: fill-opacity .4s; }
.is-complete .radar-shape { fill-opacity: .35; }  /* every goal met: the shape fills in */
.radar-dot { fill: var(--ink); }
.radar-label { fill: var(--soft); font-size: 24px; transition: fill .3s; }
.radar-label.is-done { fill: var(--ink); font-weight: 600; }

/* --- Start over --- */

.gd-reset { grid-column: 1 / -1; margin-top: -8px; text-align: right; }
.gd-reset button { padding: 6px 14px; border: 1px solid var(--line); border-radius: 6px; background: transparent; color: var(--soft); font-size: 14px; }
.gd-reset button:hover { border-color: var(--soft); color: var(--ink); }

/* --- Narrower screens --- */

/* Two columns: chat beside the chart, with the trip running across underneath,
   so its steps sit in a row and the joining lines turn sideways. */
@media (max-width: 1100px) {
  .goals-demo { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .gd-flow { grid-column: 1 / -1; grid-row: 2; }
  .gd-steps { flex-direction: row; gap: 18px; }
  .gd-steps li { flex: 1; min-width: 0; text-align: center; }
  .gd-steps li + li::before,
  .gd-steps li + li::after { left: auto; right: 100%; bottom: 50%; width: 19px; height: 1px; }
  .gd-steps li + li::after { transform: scaleX(0); transform-origin: left; }
  .gd-steps li.is-active::after,
  .gd-steps li.is-passed::after { transform: none; }
  .gd-data { min-height: 0; }
}

/* A phone: everything in one column, chat first. */
@media (max-width: 860px) {
  .goals-demo { grid-template-columns: minmax(0, 1fr); gap: 20px; padding: 16px; }
  .gd-flow { grid-row: auto; }
  .gd-messages { height: 210px; padding: 12px; }
  .gd-chips { gap: 6px; padding: 10px 12px 12px; }
  .gd-chip { padding: 6px 11px; font-size: 13px; }
  .gd-steps { gap: 10px; }
  .gd-steps li { padding: 8px 2px; }
  .gd-steps b { font-size: 13px; }
  .gd-steps span { display: none; }  /* no room for the descriptions; the names carry it */
  .gd-steps li + li::before,
  .gd-steps li + li::after { width: 11px; }
  .gd-data { padding: 10px 12px; }
  .goals-chart { max-width: 320px; margin-inline: auto; }
  .gd-reset { margin-top: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .gd-typing span { animation: none; opacity: .7; }
  .gd-steps li, .gd-steps li::after, .gd-chip, .gd-data, .radar-shape, .radar-label { transition: none; }
}
