/* avatar.css — the guide module's skin. Consumes the landing's --l-* tokens (DESIGN-DECISION section 1)
   and its type scale --t0..--t2 (section 2), with dark fallbacks so the module renders on its own; every colour is on the goldenratiocolors ladder.
   Rules: no viewport media queries here (page-shell only) — the module sizes by @container; states are
   data-state on the root with DISTINCT bar geometry per state; animation exists only inside
   @media (prefers-reduced-motion: no-preference); every target is at least 44 px; visible focus rings.
   landing-R318: the dock's last turn is never clamped (it grows, with an internal scroll only as the
   safety valve for the longest scripted answer); the transcript is a role=log wrapper around an <ol>
   so the list keeps its list semantics and the log its live region. */

.g {
  --g-paper: var(--l-paper, #0e0e0e);
  --g-raised: var(--l-raised, #252525);
  --g-edge: var(--l-edge, #3c3c3c);
  --g-rule: var(--l-rule, #616161);
  --g-ink: var(--l-ink, #f1f1f1);
  --g-ink2: var(--l-ink2, #c3c3c3);
  --g-dim: var(--l-dim, #9e9e9e);
  --g-accent: var(--l-accent, #0061ff);
  --g-accent2: var(--l-accent2, #619eff);
  --g-you: var(--l-you, #ffda9e);
  --g-deny: var(--l-deny, #ff6161);
  --g-mono: var(--l-mono, "JetBrains Mono", ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace);
  --g-body: var(--l-body, "Atkinson Hyperlegible", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif);
  --g-s0: var(--yf-s0, 6.111px);
  --g-s1: var(--yf-s1, 9.889px);
  --g-s2: var(--yf-s2, 16px);
  --g-s3: var(--yf-s3, 25.889px);
  --g-r1: var(--yf-r1, 9.889px);
  --g-tile: 56px;
  --g-t0: var(--t0, 0.8125rem);
  --g-t1: var(--t1, 0.9375rem);
  --g-t2: var(--t2, 1rem);

  container-type: inline-size;
  container-name: guide;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: var(--g-s2);
  row-gap: var(--g-s1);
  align-items: start;
  font-family: var(--g-body);
  font-size: var(--g-t2);
  line-height: 1.6;
  color: var(--g-ink);
  max-inline-size: 100%;
  min-inline-size: 0;
}
.g--dock { --g-tile: 44px; column-gap: var(--g-s1); }
.g--ask { --g-tile: 96px; }

/* ---- the presence: tile + state word ---- */
.g-presence { display: grid; justify-items: center; row-gap: var(--g-s0); inline-size: max(var(--g-tile), 4rem); }
.g-tile {
  inline-size: var(--g-tile);
  block-size: var(--g-tile);
  box-sizing: border-box;
  padding: calc(var(--g-tile) * 0.2) calc(var(--g-tile) * 0.16);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: calc(var(--g-tile) * 0.045);
  background: var(--g-raised);
  border: 1px solid var(--g-edge);
  border-radius: calc(var(--g-tile) * 0.2);
  color: var(--g-dim);
}
.g-bar {
  display: block;
  flex: 1 1 0;
  min-inline-size: 2px;
  block-size: calc(var(--h, 0.2) * 100%);
  min-block-size: 2px;
  border-radius: 999px;
  background: currentColor;
  transform-origin: 50% 100%;
}
.g-word {
  margin: 0;
  font-family: var(--g-mono);
  font-size: var(--g-t0);
  line-height: 1.2;
  letter-spacing: 0.04em;
  color: var(--g-dim);
  text-align: center;
}
.g--hero .g-word { font-size: 0.6875rem; letter-spacing: 0.02em; }
.g--dock .g-word { font-size: 0.625rem; letter-spacing: 0.02em; }
.g--dock .g-presence { inline-size: 3.5rem; }

/* ---- the four states: colour + geometry, all by DOM state ---- */
.g[data-state="idle"] .g-tile { color: var(--g-dim); border-color: var(--g-edge); }
.g[data-state="idle"] .g-bar:nth-child(1) { --h: 0.16; }
.g[data-state="idle"] .g-bar:nth-child(2) { --h: 0.24; }
.g[data-state="idle"] .g-bar:nth-child(3) { --h: 0.3; }
.g[data-state="idle"] .g-bar:nth-child(4) { --h: 0.34; }
.g[data-state="idle"] .g-bar:nth-child(5) { --h: 0.3; }
.g[data-state="idle"] .g-bar:nth-child(6) { --h: 0.24; }
.g[data-state="idle"] .g-bar:nth-child(7) { --h: 0.16; }

.g[data-state="listening"] .g-tile { color: var(--g-you); border-color: var(--g-you); }
.g[data-state="listening"] .g-bar:nth-child(1) { --h: 0.92; }
.g[data-state="listening"] .g-bar:nth-child(2) { --h: 0.6; }
.g[data-state="listening"] .g-bar:nth-child(3) { --h: 0.34; }
.g[data-state="listening"] .g-bar:nth-child(4) { --h: 0.2; }
.g[data-state="listening"] .g-bar:nth-child(5) { --h: 0.34; }
.g[data-state="listening"] .g-bar:nth-child(6) { --h: 0.6; }
.g[data-state="listening"] .g-bar:nth-child(7) { --h: 0.92; }

.g[data-state="thinking"] .g-tile { color: var(--g-ink); border-color: var(--g-rule); }
.g[data-state="thinking"] .g-bar:nth-child(odd) { --h: 0.26; }
.g[data-state="thinking"] .g-bar:nth-child(even) { --h: 0.72; }

.g[data-state="speaking"] .g-tile { color: var(--g-accent2); border-color: var(--g-accent2); }
.g[data-state="speaking"] .g-bar:nth-child(1) { --h: 0.3; }
.g[data-state="speaking"] .g-bar:nth-child(2) { --h: 0.56; }
.g[data-state="speaking"] .g-bar:nth-child(3) { --h: 0.82; }
.g[data-state="speaking"] .g-bar:nth-child(4) { --h: 1; }
.g[data-state="speaking"] .g-bar:nth-child(5) { --h: 0.82; }
.g[data-state="speaking"] .g-bar:nth-child(6) { --h: 0.56; }
.g[data-state="speaking"] .g-bar:nth-child(7) { --h: 0.3; }
.g[data-state="listening"] .g-word { color: var(--g-you); }
.g[data-state="speaking"] .g-word { color: var(--g-accent2); }
.g[data-state="thinking"] .g-word { color: var(--g-ink2); }

/* ---- motion, only where the visitor allows it ---- */
@media (prefers-reduced-motion: no-preference) {
  .g-tile { transition: color 220ms ease, border-color 220ms ease; }
  .g-bar { transition: block-size 180ms cubic-bezier(0.2, 0.8, 0.2, 1); }
  .g[data-state="idle"] .g-bar { animation: g-breathe 4.8s ease-in-out infinite; }
  .g[data-state="listening"] .g-bar { animation: g-ear 1.6s ease-in-out infinite; }
  .g[data-state="thinking"] .g-bar { animation: g-ripple 900ms ease-in-out infinite; }
  .g[data-state="speaking"] .g-bar { animation: g-level 640ms ease-in-out infinite alternate; }
  .g-bar:nth-child(1) { animation-delay: 0ms; }
  .g-bar:nth-child(2) { animation-delay: 90ms; }
  .g-bar:nth-child(3) { animation-delay: 180ms; }
  .g-bar:nth-child(4) { animation-delay: 270ms; }
  .g-bar:nth-child(5) { animation-delay: 360ms; }
  .g-bar:nth-child(6) { animation-delay: 450ms; }
  .g-bar:nth-child(7) { animation-delay: 540ms; }
  .g-turn:last-child { animation: g-rise 260ms cubic-bezier(0.2, 0.8, 0.2, 1) both; }
  .g-chip, .g-send, .g-btn { transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease; }
}
@keyframes g-breathe { 0%, 100% { transform: scaleY(1); } 50% { transform: scaleY(1.28); } }
@keyframes g-ear { 0%, 100% { transform: scaleY(1); } 50% { transform: scaleY(0.72); } }
@keyframes g-ripple { 0%, 100% { transform: scaleY(0.4); } 50% { transform: scaleY(1.3); } }
@keyframes g-level { from { transform: scaleY(0.55); } to { transform: scaleY(1); } }
@keyframes g-rise { from { opacity: 0; translate: 0 4px; } to { opacity: 1; translate: 0 0; } }

/* ---- the body: log, chips, composer, notice row ---- */
.g-body { display: grid; row-gap: var(--g-s1); min-inline-size: 0; }
.g-log { min-inline-size: 0; }
.g-turns {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  row-gap: var(--g-s1);
  min-inline-size: 0;
}
/* the Ask transcript: a recessed, framed, scrolling log (tabindex=0 in the markup so the keyboard can scroll it) */
.g--ask .g-log {
  max-block-size: 22rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--g-s2);
  background: var(--g-paper);
  border: 1px solid var(--g-edge);
  border-radius: var(--g-r1);
}
.g-log--brief .g-turn:not(:nth-last-child(-n + 2)) { display: none; }
.g-turn { display: grid; row-gap: 2px; min-inline-size: 0; }
.g-meta {
  display: flex;
  gap: var(--g-s1);
  align-items: baseline;
  font-family: var(--g-mono);
  font-size: var(--g-t0);
  line-height: 1.2;
  letter-spacing: 0.04em;
  color: var(--g-dim);
}
.g-who { text-transform: uppercase; font-size: 0.6875rem; letter-spacing: 0.1em; }
.g-at { font-variant-numeric: tabular-nums; }
.g-text { margin: 0; color: var(--g-ink); overflow-wrap: anywhere; max-inline-size: 62ch; }
.g-turn--you .g-text { color: var(--g-you); }
.g-turn--you .g-who { color: var(--g-you); }
.g--dock .g-text { font-size: var(--g-t1); line-height: 1.45; }

.g-chips { display: flex; flex-wrap: wrap; gap: var(--g-s1); }
.g-chip, .g-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--g-s0);
  min-block-size: 44px;
  padding: var(--g-s0) var(--g-s2);
  border: 1px solid var(--g-edge);
  border-radius: 999px;
  background: var(--g-raised);
  color: var(--g-ink2);
  font: inherit;
  font-size: var(--g-t1);
  line-height: 1.2;
  cursor: pointer;
  text-align: start;
}
.g-chip:hover, .g-btn:hover { color: var(--g-ink); border-color: var(--g-rule); }
.g-btn[aria-pressed="true"] { color: var(--g-ink); border-color: var(--g-accent2); }
.g-btn[disabled] { cursor: default; opacity: 0.6; }
.g-btn .ico, .g-send .ico { font-size: 1.125em; flex: none; }
.g-btn--mic.g-btn--live { color: var(--g-you); border-color: var(--g-you); }

/* the composer: the field and the enter key on one row, the tools (voice, mic, model) on a row of their own
   beneath — the model control's label alone is wider than most fields. Only a really wide guide (64rem and
   up, the 1440 Ask panel) takes the tools inline. The send column is FIXED at 44 px so a spanning tools row
   can never grow it and starve the field (measured 34 px wide at 320, 844 and 834 before). */
.g-composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  align-items: center;
  gap: var(--g-s1);
  min-inline-size: 0;
}
.g-tools { display: flex; flex-wrap: wrap; gap: var(--g-s1); align-items: center; grid-column: 1 / -1; grid-row: 2; min-inline-size: 0; }
.g-tools:empty { display: none; }
.g-btn { min-inline-size: 0; }
@container guide (min-width: 64rem) {
  .g-composer { grid-template-columns: minmax(0, 1fr) auto 44px; }
  .g-tools { grid-column: auto; grid-row: auto; flex-wrap: nowrap; }
}
.g-in {
  box-sizing: border-box;
  inline-size: 100%;
  min-inline-size: 0;
  min-block-size: 44px;
  padding: var(--g-s1) var(--g-s2);
  border: 1px solid var(--g-edge);
  border-radius: var(--g-r1);
  background: var(--g-paper);
  color: var(--g-ink);
  font: inherit;
  font-size: max(1rem, var(--g-t2));
}
.g-in::placeholder { color: var(--g-dim); opacity: 1; }
.g-send {
  box-sizing: border-box;
  inline-size: 44px;
  block-size: 44px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--g-edge);
  border-radius: var(--g-r1);
  background: var(--g-raised);
  color: var(--g-ink2);
  font-size: 1.125rem;
  cursor: pointer;
}
.g-send:hover { color: var(--g-ink); border-color: var(--g-rule); }
.g-in:not(:placeholder-shown) + .g-tools + .g-send { color: var(--g-accent2); border-color: var(--g-accent2); }
.g--dock .g-send { border-radius: var(--g-r1); }
.g-row[hidden] { display: none; }
.g-row {
  margin: 0;
  font-family: var(--g-mono);
  font-size: var(--g-t0);
  line-height: 1.4;
  color: var(--g-dim);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: var(--g-s2);
  padding-block: var(--g-s0);
  border-block-start: 1px solid var(--g-edge);
  overflow-wrap: anywhere;
}
.g-row::before { content: "MODEL"; letter-spacing: 0.1em; color: var(--g-ink2); }
.g-row[data-tone="deny"] { color: var(--g-deny); }
.g-row[data-tone="ok"] { color: var(--g-ink); }

/* ---- shapes ---- */
.g--dock {
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas: "log log" "presence composer" "row row";
  align-items: center;
  row-gap: var(--g-s1);
}
.g--dock .g-body { display: contents; }
.g--dock .g-presence { grid-area: presence; }
.g--dock .g-log { grid-area: log; }
.g--dock .g-composer { grid-area: composer; }
.g--dock .g-row { grid-area: row; }
/* at rest the dock is compact — tile, field, enter, the state word; the script lines live in the hero row and the
   Ask section. Once the visitor has asked something (data-live, set by the module on the first "you" turn) the
   dock carries the latest turn, whole. */
.g--dock:not([data-live="1"]) .g-log { display: none; }
.g--dock .g-log:has(.g-turns:empty) { display: none; }
.g--dock .g-log .g-turn:not(:last-child) { display: none; }
/* the dock's last turn GROWS to its full sentence; the internal scroll is only the valve for a turn taller
   than eight lines, which no scripted answer reaches (the longest, keyboard, is seven at 390 px) */
.g--dock .g-log { max-block-size: 12rem; overflow-y: auto; overscroll-behavior: contain; }
.g--hero .g-body { row-gap: var(--g-s1); }
.g--hero .g-log { order: 2; }
.g--hero .g-composer { order: 1; }
.g--hero .g-row { order: 3; }

/* the composer folds its tools under the field when the guide is narrow */
@container guide (max-width: 30rem) {
  .g--ask .g-log { max-block-size: 16rem; }
}
/* STACKING: a container query cannot restyle its own container, and .g IS the guide container — so the
   Ask shape's stacked layout on a narrow panel (presence above, transcript full width) is written by the
   PAGE against the panel that holds the guide (landing.css, @container ask). */

/* ---- focus, screen readers, forced colours ---- */
.g :focus-visible { outline: 3px solid var(--g-accent2); outline-offset: 2px; }
.g-in:focus-visible { outline-offset: 1px; border-color: var(--g-accent2); }
.g-sr { position: absolute; inline-size: 1px; block-size: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }
@media (forced-colors: active) {
  .g-tile, .g-in, .g-chip, .g-btn, .g-send, .g-row, .g--ask .g-log { border-color: CanvasText; }
  .g-bar { background: CanvasText; }
  .g-btn[aria-pressed="true"] { border-color: Highlight; }
}
