/* SIM BOT (2026-10-15, first named Ask SimFather): the page for the research assistant (ask.html,
 * ask.js).
 *
 * THE THIRD DRAWING (2026-10-16): a chat app. One centred stage; before the first question the
 * seal is Sim Bot's face, with a welcome, the box you type in and six questions to tap; once a chat
 * is going, your questions sit on the right, Sim Bot's answers on the left with their sources as
 * chips and every figure in the data face, and the box is pinned to the bottom of the screen.
 * Every value is a site token (site.css), so the light theme follows.
 */

.page-ask .sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Positioned so the page sits above the site's glow layer (.atmos is absolute at z-index 0, and
   unpositioned content paints under it). */
.ask { position: relative; z-index: 1; }

.ask-app {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s5);
  padding-block: var(--s4) var(--s8);
}
.ask-app > * { width: 100%; max-width: 48rem; min-width: 0; }

/* ---- the top bar: Sim Bot's name once a chat is going, History and New chat ------------------- */
.ask-bar { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); min-height: 40px; }
.ask-bar__name {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  margin: 0;
  font: 600 15px/1 var(--ui);
  color: var(--text);
}
.ask-app:not([data-chatting]) .ask-bar__name { visibility: hidden; }
.ask-bar__seal { width: 24px; height: 24px; border-radius: 50%; }
.ask-bar__actions { display: flex; gap: var(--s2); margin-left: auto; }
.ask-tool {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 var(--s3);
  font: 500 14px/1 var(--ui);
  color: var(--text);
  background: var(--field-bg);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-pill);
  cursor: pointer;
}
.ask-tool[hidden] { display: none; }
.ask-tool svg { width: 16px; height: 16px; color: var(--brass); }
.ask-tool:hover,
.ask-tool[aria-expanded="true"] { border-color: var(--line); background: var(--panel-2); }
.ask-tool__n { font-family: var(--mono); font-size: 12px; font-variant-numeric: tabular-nums; color: var(--brass); }

/* ---- history: a list that drops down under the bar --------------------------------------------- */
.ask-recent {
  display: grid;
  gap: var(--s2);
  padding: var(--s3) var(--s4);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 18px 40px -20px var(--shadow);
}
.ask-recent[hidden] { display: none; }
.ask-recent__label { margin: 0; font: 600 11px/1.4 var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.ask-recent__list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; }
.ask-recent__item {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: var(--s2) var(--s3);
  text-align: left;
  font: 400 15px/1.4 var(--ui);
  color: var(--text);
  background: none;
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ask-recent__item:hover,
.ask-recent__item[aria-current="true"] { background: var(--field-bg); color: var(--brass-bright); }

/* ---- the welcome ------------------------------------------------------------------------------- */
.ask-hero { display: grid; justify-items: center; gap: var(--s4); padding-top: var(--s4); text-align: center; }
.ask-app[data-chatting] .ask-hero { display: none; }

/* Sim Bot's face: the seal inside a slowly turning gold ring, on a soft glow. */
.ask-orb { position: relative; display: grid; place-items: center; width: 104px; height: 104px; }
.ask-orb::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0 18%, var(--brass) 38%, transparent 58%, var(--brass-bright) 82%, transparent 100%);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 2px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 2px));
  animation: ask-turn 9s linear infinite;
}
.ask-orb::after {
  content: "";
  position: absolute;
  inset: -28px;
  z-index: -1;
  border-radius: 50%;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--brass) 26%, transparent), transparent);
}
.ask-orb img { width: 88px; height: 88px; border-radius: 50%; }
@keyframes ask-turn { to { transform: rotate(360deg); } }

.ask-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  margin: 0;
  padding: 6px var(--s3);
  font: 500 13px/1.2 var(--ui);
  color: var(--muted);
  background: var(--field-bg);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-pill);
}
.ask-pill__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--brass); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brass) 22%, transparent); }
.ask-pill__sep { color: var(--line); }
.ask-hero__title {
  margin: 0;
  max-width: 16ch;
  font-family: var(--display);
  font-size: clamp(2.1rem, 1.3rem + 3vw, 3.4rem);
  font-weight: 700;
  line-height: 1.06;
  letter-spacing: -0.03em;
  color: var(--text);
  background: linear-gradient(180deg, var(--text) 35%, color-mix(in srgb, var(--brass-bright) 75%, var(--text)));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.ask-hero__lede { margin: 0; max-width: 34rem; font-size: 17px; line-height: 1.55; color: var(--muted); }

/* ---- the box you type in: the one lit thing on the page ---------------------------------------- */
.ask-compose {
  display: grid;
  background: var(--panel);
  border: 1px solid color-mix(in srgb, var(--brass) 38%, transparent);
  border-radius: 22px;
  box-shadow:
    0 0 0 4px color-mix(in srgb, var(--brass) 7%, transparent),
    0 0 56px -18px color-mix(in srgb, var(--brass) 55%, transparent),
    0 24px 60px -28px var(--shadow);
  transition: border-color 180ms ease, box-shadow 180ms ease;
}
.ask-compose:focus-within {
  border-color: var(--brass);
  box-shadow:
    0 0 0 4px color-mix(in srgb, var(--brass) 16%, transparent),
    0 0 64px -16px color-mix(in srgb, var(--brass) 65%, transparent),
    0 24px 60px -28px var(--shadow);
}
.ask-compose__input {
  min-height: 56px;
  max-height: 12rem;
  padding: var(--s4) var(--s5) var(--s1);
  font: 400 max(16px, 17px)/1.45 var(--ui);
  color: var(--text);
  background: none;
  border: 0;
  resize: none;
  outline: none;
}
.ask-compose__input::placeholder { color: var(--muted); }
.ask-compose__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  padding: var(--s1) var(--s2) var(--s2) var(--s5);
}
.ask-compose__meta { margin: 0; font: 500 12px/1.4 var(--mono); font-variant-numeric: tabular-nums; color: var(--muted); }
.ask-compose__meta.is-err { color: var(--danger); }
.ask-send {
  display: grid;
  place-items: center;
  flex: none;
  width: 42px;
  height: 42px;
  padding: 0;
  color: var(--btn-gilt-text);
  background: var(--btn-gilt-bg);
  border: 0;
  border-radius: 50%;
  box-shadow: 0 6px 18px -6px color-mix(in srgb, var(--brass) 70%, transparent);
  cursor: pointer;
  transition: transform 160ms ease, opacity 160ms ease;
}
.ask-send svg { width: 20px; height: 20px; }
.ask-send:hover { transform: translateY(-1px); }
.ask-send:disabled { opacity: 0.4; cursor: default; transform: none; box-shadow: none; }

/* Once a chat is going the box stays on screen, pinned to the bottom of it. */
.ask-app[data-chatting] .ask-compose { position: sticky; bottom: calc(var(--s3) + env(safe-area-inset-bottom, 0px)); z-index: 4; }
/* On a phone the tab bar (site.css, 2026-10-16) owns the bottom of the screen: the box rides above it. */
@media (max-width: 760px) {
  html:has(.tabbar) .ask-app[data-chatting] .ask-compose { bottom: calc(64px + var(--s3) + env(safe-area-inset-bottom, 0px)); }
  html:has(.tabbar)[data-sf-consent-bar] .ask-app[data-chatting] .ask-compose { bottom: calc(64px + var(--s3) + var(--sf-consent-h, 0px) + env(safe-area-inset-bottom, 0px)); }
}

/* ---- six questions to start with -------------------------------------------------------------- */
.ask-start[hidden] { display: none; }
.ask-ideas { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s3); }
.ask-idea {
  display: grid;
  align-content: start;
  gap: var(--s2);
  width: 100%;
  height: 100%;
  padding: var(--s4);
  text-align: left;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: 16px;
  cursor: pointer;
  transition: border-color 180ms ease, transform 180ms ease, box-shadow 180ms ease;
}
.ask-idea:hover {
  border-color: color-mix(in srgb, var(--brass) 55%, transparent);
  transform: translateY(-2px);
  box-shadow: 0 14px 34px -18px color-mix(in srgb, var(--brass) 60%, transparent);
}
.ask-idea__icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: var(--brass);
  background: color-mix(in srgb, var(--brass) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--brass) 28%, transparent);
  border-radius: 10px;
}
.ask-idea__icon svg { width: 18px; height: 18px; }
.ask-idea__kind { font: 600 11px/1.3 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--brass); }
.ask-idea__q { font: 500 15px/1.4 var(--ui); color: var(--text); }
@media (max-width: 759px) { .ask-ideas { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 479px) {
  .ask-ideas { grid-template-columns: minmax(0, 1fr); gap: var(--s2); }
  .ask-idea { grid-template-columns: 34px minmax(0, 1fr); align-items: center; column-gap: var(--s3); padding: var(--s3); }
  .ask-idea__icon { grid-row: span 2; }
}

/* ---- the conversation ------------------------------------------------------------------------- */
.ask-thread { display: grid; gap: var(--s6); padding-top: var(--s2); }
.ask-thread:empty { display: none; }
/* scroll-margin: a new turn scrolls into view below the sticky masthead, not under it. */
.ask-turn { display: grid; gap: var(--s4); scroll-margin-top: calc(var(--masthead) + var(--s5)); }
.ask-you {
  justify-self: end;
  max-width: 80%;
  margin: 0;
  padding: var(--s3) var(--s4);
  font: 400 16px/1.5 var(--ui);
  color: var(--text);
  background: color-mix(in srgb, var(--brass) 13%, var(--panel));
  border: 1px solid color-mix(in srgb, var(--brass) 30%, transparent);
  border-radius: 18px 18px 6px 18px;
  overflow-wrap: anywhere;
}
.ask-bot { display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: var(--s3); align-items: start; }
.ask-bot__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--line), 0 0 18px -4px color-mix(in srgb, var(--brass) 60%, transparent);
}
.ask-bot__main { display: grid; gap: var(--s2); min-width: 0; }
.ask-bot__head { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s1) var(--s3); margin: 0; padding-top: 7px; }
.ask-bot__name { font: 600 14px/1.2 var(--ui); color: var(--text); }
.ask-bot__time { font: 500 12px/1.2 var(--mono); font-variant-numeric: tabular-nums; color: var(--muted); }
.ask-bot__status { display: flex; align-items: center; gap: var(--s2); margin: 0; font: 400 14px/1.4 var(--ui); color: var(--muted); }
.ask-dots { display: inline-flex; gap: 4px; }
.ask-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--brass); animation: ask-dot 1.2s ease-in-out infinite; }
.ask-dots i:nth-child(2) { animation-delay: 0.15s; }
.ask-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes ask-dot { 0%, 80%, 100% { opacity: 0.25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.ask-bot__text { display: grid; gap: var(--s3); font-size: 16px; line-height: 1.65; color: var(--text); overflow-wrap: anywhere; }
.ask-bot__text:empty { display: none; }
.ask-bot__text p { margin: 0; }
.ask-bot__text ul { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s1); }
.ask-bot__text li { position: relative; padding-left: var(--s5); }
.ask-bot__text li::before { content: ""; position: absolute; left: 2px; top: 0.82em; width: 10px; height: 2px; border-radius: 1px; background: var(--brass); }
.ask-bot__text strong { font-weight: 650; color: var(--parchment); }
/* Every figure in an answer is set in the data face. */
.ask-num { font-family: var(--mono); font-size: 0.92em; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; color: var(--brass-bright); }
.ask-bot.is-error .ask-bot__text { color: var(--danger); }

/* The sources it read, as chips that lead to the page they came from. */
.ask-src { display: flex; flex-wrap: wrap; gap: var(--s2); margin: var(--s1) 0 0; }
.ask-src__chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 var(--s3);
  font: 500 12px/1 var(--ui);
  color: var(--brass);
  text-decoration: none;
  background: var(--field-bg);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-pill);
}
.ask-src__chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.7; }
a.ask-src__chip:hover { border-color: var(--line); color: var(--brass-bright); }

/* ---- signed out ---------------------------------------------------------------------------------- */
.ask-signin {
  display: flex;
  gap: var(--s4);
  align-items: flex-start;
  padding: var(--s5);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
}
.ask-signin[hidden] { display: none; }
.ask-signin__seal { flex: none; width: 40px; height: 40px; border-radius: 50%; }
.ask-signin__title { margin: 0 0 var(--s1); font-weight: 600; color: var(--text); }
.ask-signin__body { margin: 0; color: var(--muted); }
.ask-signin__actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s4); margin: var(--s3) 0 0; }
.ask-signin__link { color: var(--brass); }

.ask-fine { margin: 0; font-size: 12px; line-height: 1.5; text-align: center; color: var(--muted); }
.ask-nowrap { white-space: nowrap; }

.ask-tool,
.ask-recent__item,
a.ask-src__chip { transition: color 160ms ease, border-color 160ms ease, background-color 160ms ease; }
.ask-tool:focus-visible,
.ask-recent__item:focus-visible,
.ask-idea:focus-visible,
.ask-send:focus-visible,
a.ask-src__chip:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  .ask-orb::before,
  .ask-dots i { animation: none; }
  .ask-idea:hover,
  .ask-send:hover { transform: none; }
}
