/* The assistant answer that writes itself with the sources lighting up: the answer panel of a made-up research
   assistant, Quarry, on a near black page. A glass panel with a beam of light running round its edge while it works,
   the answer written word by word, small citation pills in the text and four source cards underneath. */
:root {
  --page: #09090b;              /* the page */
  --panel: #111114;             /* the body of the panel */
  --edge: rgba(255, 255, 255, 0.075); /* its edge at rest */
  --ink: #e9e9ee;               /* the answer */
  --muted: #85858f;             /* the small words */
  --faint: #4a4a53;             /* words not written yet, rules */
  --accent: #8db4ff;            /* the light: beam, pills, the lit sources */
  --accent-2: #b59bff;          /* the second colour of the beam */
  --mark: rgba(141, 180, 255, 0.17); /* the sentence a pill backs, when marked */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
  overflow-x: clip;
}

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--ink);
  font-family: 'Mona Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

.stage {
  position: relative;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: clamp(10px, 3vh, 28px) clamp(10px, 3vw, 28px);
  overflow: hidden;
  background:
    radial-gradient(60% 45% at 50% 0%, rgba(141, 180, 255, 0.07), transparent 70%),
    var(--page);
}

/* ------------------------------------------------------------------ the panel */
.panel {
  --pad: clamp(14px, 3.4vh, 24px);
  position: relative;
  width: min(94vw, 560px);
  padding: var(--pad);
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0) 38%),
    var(--panel);
  box-shadow:
    inset 0 0 0 1px var(--edge),
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    0 1px 2px rgba(0, 0, 0, 0.5),
    0 24px 60px -24px rgba(0, 0, 0, 0.9),
    0 40px 120px -40px rgba(70, 100, 200, 0.18);
  opacity: 0;
}

/* the beam that runs round the edge while Quarry works: a conic light masked down to a 1px ring */
.panel__beam {
  --a: 0deg;
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: conic-gradient(from var(--a), transparent 0deg, transparent 250deg, var(--accent-2) 300deg, var(--accent) 335deg, #ffffff 350deg, transparent 360deg);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  opacity: 0;
  pointer-events: none;
}

/* a soft sheen on the top edge */
.panel__sheen {
  position: absolute;
  left: 12%;
  right: 12%;
  top: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.28), transparent);
  pointer-events: none;
}

.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: clamp(10px, 2.4vh, 16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 640;
  font-stretch: 108%;
  letter-spacing: -0.01em;
}

.brand__mark {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.4;
  stroke-linejoin: round;
}

.brand__cut {
  stroke: var(--accent);
}

/* the status pill: Searching 4 sources, then Answer ready */
.status {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px 0 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.07);
  font-size: 11.5px;
  font-weight: 520;
  color: var(--muted);
  white-space: nowrap;
}

.status__icon {
  width: 14px;
  height: 14px;
  flex: none;
  fill: none;
  overflow: visible;
}

.status__track {
  stroke: rgba(255, 255, 255, 0.1);
  stroke-width: 1.5;
}

.status__arc {
  stroke: var(--accent);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-dasharray: 0.28 1;
  transform-origin: 8px 8px;
}

.status__check {
  stroke: var(--accent);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}

.status__words {
  position: relative;
  display: inline-grid;
  overflow: hidden;
  height: 16px;
  line-height: 16px;
}

.status__word {
  grid-area: 1 / 1;
}

/* the searching words shimmer while Quarry reads */
.status__word--search {
  background: linear-gradient(100deg, var(--muted) 0%, var(--muted) 40%, #ffffff 50%, var(--muted) 60%, var(--muted) 100%);
  background-size: 250% 100%;
  background-position: 100% 0;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.status__word--ready {
  color: var(--ink);
  opacity: 0;
}

.status__time {
  font-variant-numeric: tabular-nums;
  color: var(--faint);
  max-width: 0;
  opacity: 0;
  overflow: hidden;
}

.query {
  margin: 0 0 clamp(8px, 1.8vh, 12px);
  font-size: clamp(14.5px, 2.4vh + 5px, 22px);
  line-height: 1.25;
  font-weight: 620;
  font-stretch: 104%;
  letter-spacing: -0.015em;
  color: #ffffff;
  text-wrap: balance;
}

/* ------------------------------------------------------------------ the answer */
.answer {
  margin: 0;
  font-size: clamp(12.5px, 1.5vh + 7px, 17px);
  line-height: 1.55;
  font-weight: 400;
  color: var(--ink);
  text-wrap: pretty;
}

.nb {
  white-space: nowrap;
}

.w {
  display: inline-block;
  will-change: transform, opacity, filter;
}

.sent {
  border-radius: 4px;
  background-image: linear-gradient(var(--mark), var(--mark));
  background-repeat: no-repeat;
  background-position: 0 50%;
  background-size: 0% 100%;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  transition: color 0.3s ease;
}

.sent.is-marked {
  color: #ffffff;
}

/* a citation pill in the text */
.cite {
  display: inline-grid;
  place-items: center;
  min-width: 17px;
  height: 16px;
  margin: 0 1px 0 3px;
  padding: 0 4px;
  border: 0;
  border-radius: 999px;
  background: rgba(141, 180, 255, 0.13);
  box-shadow: inset 0 0 0 1px rgba(141, 180, 255, 0.32);
  color: var(--accent);
  font: 600 10px/1 'Mona Sans Variable', system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  vertical-align: 0.12em;
  cursor: pointer;
  opacity: 0;
  -webkit-tap-highlight-color: transparent;
}

.cite.is-on {
  background: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.5), 0 0 14px rgba(141, 180, 255, 0.55);
  color: #0b1020;
}

.cite:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ------------------------------------------------------------------ the sources */
.sources {
  display: flex;
  gap: 6px;
  margin: clamp(12px, 2.6vh, 18px) 0 0;
  padding: clamp(10px, 2.2vh, 14px) 0 0;
  list-style: none;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.src {
  flex: 1 1 0;
  min-width: 0;
  container-type: inline-size;
}

/* a card too narrow for its words shows only its tile and its number */
@container (max-width: 104px) {
  .src__text {
    opacity: 0;
  }

  .src__num {
    top: 50%;
    right: 9px;
    font-size: 11px;
    color: var(--muted);
    transform: translateY(-50%);
  }
}

.src__text,
.src__num {
  transition: opacity 0.25s ease, color 0.25s ease;
}

.src__lift {
  position: relative;
  display: flex;
  align-items: center;
  gap: 7px;
  height: clamp(44px, 7vh + 12px, 54px);
  padding: 0 15px 0 8px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.025);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  overflow: hidden;
  opacity: 0;
  cursor: default;
}

/* the light a source takes when it is cited */
.src__glow {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    radial-gradient(120% 90% at 20% 0%, rgba(141, 180, 255, 0.2), transparent 60%),
    rgba(141, 180, 255, 0.03);
  box-shadow: inset 0 0 0 1px rgba(141, 180, 255, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.14);
  opacity: 0;
  pointer-events: none;
}

.src__tile {
  position: relative;
  display: grid;
  place-items: center;
  flex: none;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: linear-gradient(160deg, color-mix(in srgb, var(--tile) 100%, #fff 18%), var(--tile));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16), 0 2px 6px rgba(0, 0, 0, 0.4);
  color: #ffffff;
  font-size: 10.5px;
  font-weight: 700;
}

.src__text {
  position: relative;
  display: grid;
  min-width: 0;
  flex: 1 1 auto;
  gap: 1px;
}

.src__site,
.src__title {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.src__site {
  font-size: 10.5px;
  color: var(--muted);
}

.src__title {
  font-size: 11.5px;
  font-weight: 560;
  color: var(--ink);
}

.src__num {
  position: absolute;
  top: 5px;
  right: 6px;
  font-size: 9px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--faint);
}

/* the pointer of the pilot */
.pointer {
  position: absolute;
  left: 0;
  top: 0;
  width: 20px;
  height: 20px;
  fill: #ffffff;
  stroke: #09090b;
  stroke-width: 1.1;
  stroke-linejoin: round;
  filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.55));
  opacity: 0;
  pointer-events: none;
  z-index: 5;
}

@media (max-width: 420px) {
  .src__lift {
    padding: 0 12px 0 6px;
    gap: 6px;
  }

  .src__tile {
    width: 18px;
    height: 18px;
  }
}
