/**
 * The assistant.
 *
 * Every colour, radius and face is taken from the site's own tokens rather than
 * chosen here, with the Winter values as fallbacks so the widget still resolves
 * on a page where the portfolio stylesheet did not load. That is what keeps this
 * from looking like a third-party box dropped onto the design.
 *
 * The avatar is four stacked layers inside one box, all positioned as
 * percentages of that box: the base photograph, one clipped eye layer per iris,
 * and one lid strip per eye above them. Because every offset is a percentage,
 * changing --hac-size is the only thing needed to resize the whole assembly.
 */

.hac {
  --hac-size: 136px;
  --hac-edge: clamp(14px, 2.4vw, 26px);
  --hac-radius: 14px;
  --hac-panel-w: 372px;

  --hac-ink: var(--text, #E9EEF6);
  --hac-ink-2: var(--text-2, #93A3B8);
  --hac-bg: var(--panel, #131B26);
  --hac-line: var(--line, #24303F);
  --hac-accent: var(--accent, #5B8CFF);
  --hac-accent-hi: var(--accent-hi, #8FB0FF);
  --hac-accent-mute: var(--accent-mute, rgba(91, 140, 255, .16));
  --hac-display: var(--display, 'Archivo', system-ui, sans-serif);
  --hac-mono: var(--mono, 'Plex Mono', ui-monospace, monospace);

  position: fixed;
  right: var(--hac-edge);
  bottom: var(--hac-edge);
  /*
   * Above everything this site puts on screen, and chosen by reading them
   * rather than by picking a large number:
   *
   *   .drawer  99   the mobile menu           (theme.css)
   *   .nav    100   the sticky header         (theme.css)
   *   .ppanel 120   the project detail panel  (components.css)
   *   .skip   200   the skip link             (theme.css)
   *
   * At 90 the panel was underneath all of them. On a phone, where the panel
   * covers the screen, that put the site header and its burger on top of the
   * chat -- so the close button sat under the menu icon and the thing could be
   * impossible to shut.
   */
  z-index: 210;
  display: flex;
  /* Reversed so the panel opens upward and the avatar keeps its place. In DOM
     order the trigger comes first, which is what a keyboard should reach first;
     laying it out in column order instead would push the avatar 400px up the
     screen the moment the panel appears. */
  flex-direction: column-reverse;
  align-items: flex-end;
  gap: 12px;
  /* The wrapper must not intercept anything: only its children are targets. */
  pointer-events: none;
}

.hac[hidden] { display: none; }

.hac__defs { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ---------------------------------------------------------------- trigger */

.hac__trigger {
  position: relative;
  display: block;
  padding: 0;
  margin: 0;
  border: 0;
  background: none !important;
  cursor: pointer;
  pointer-events: auto;
  line-height: 0;
  /* Tap highlight and callout suppressed: the avatar is a picture of a person
     and a blue flash across the face reads badly. */
  -webkit-tap-highlight-color: transparent;
}

/*
 * The avatar carries no surface of any kind -- no disc, glow, card or gradient,
 * in any state. It is a cut-out head floating on the page, and hover feedback is
 * applied to the head itself (a fraction of a percent of scale, written by the
 * runtime along with the parallax) rather than to something appearing behind it.
 */

.hac__avatar {
  position: relative;
  display: block;
  width: var(--hac-size);
  /* Scale and parallax are written here by the runtime; the transition covers
     only the hover step, since tracking is driven frame by frame. */
  transform-origin: 50% 88%;
  will-change: transform;
}

.hac__base {
  display: block;
  width: 100%;
  height: auto;
  /* A photographic cut-out with no ground under it needs a contact shadow, or
     it reads as pasted on. */
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, .45));
}

.hac__eye {
  position: absolute;
  inset: 0;
  display: block;
  pointer-events: none;
}

.hac__iris {
  position: absolute;
  display: block;
  /* Placed by its centre, so the markup never encodes the sprite's margin. The
     runtime appends the gaze offset to this same transform. */
  transform: translate(-50%, -50%);
  will-change: transform;
}

.hac__lid {
  position: absolute;
  display: block;
  transform: translateY(0);
  will-change: transform;
  pointer-events: none;
}

/* ---- the discovery cue ---- */

/*
 * A head floating at the edge of a page is decoration until something says
 * otherwise. This is that something: a chip in the site's own idiom -- mono,
 * hairline border, the same pill the project cards use for their roles --
 * carrying a message glyph and the assistant's name.
 *
 * It is positioned against the trigger, not laid out beside it, so it adds
 * nothing to the flex column the panel and the avatar share and cannot alter
 * where either of them sits. It rides along wherever the avatar is dragged
 * for free.
 *
 * Vertically it sits at the level of the mouth rather than the eyes. Beside
 * the eyes it competes with the gaze; level with the mouth it reads as
 * something the face is saying, which is the relationship wanted, and it keeps
 * clear of the cap and the eyes either way.
 */

.hac__cue {
  position: absolute;
  top: 58%;
  /* Toward the middle of the screen, away from the edge the avatar anchors to;
     mirrored below when the visitor has dragged it to the other side. */
  right: calc(100% + 6px);
  transform: translateY(-50%);

  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px 5px 8px;
  border: 1px solid var(--hac-line);
  border-radius: 20px;
  background: var(--hac-bg);
  box-shadow: 0 6px 16px rgba(0, 0, 0, .16);

  font-family: var(--hac-mono);
  font-size: 10.5px;
  letter-spacing: .05em;
  line-height: 1;
  white-space: nowrap;
  color: var(--hac-ink-2);

  /* Its own cursor. The head says grab, because it can be moved; the chip says
     click, because that is the only thing it does. */
  cursor: pointer;
  transition: border-color .18s ease, color .18s ease, opacity .18s ease;
}

.hac__cue svg {
  width: 13px;
  height: 13px;
  flex: none;
  color: var(--hac-accent);
  transition: transform .18s ease;
}

.hac[data-hac-side="left"] .hac__cue {
  right: auto;
  left: calc(100% + 6px);
}

/*
 * First visit. The chip is not there when the page arrives; it appears once the
 * avatar has settled and had a moment to be looked at, drifting the last few
 * pixels toward the head so the two read as one object. One movement, once --
 * nothing here loops.
 */
@media (prefers-reduced-motion: no-preference) {
  .hac__cue {
    animation: hac-cue-in .5s cubic-bezier(.22, .68, .36, 1) 1.1s both;
  }
  @keyframes hac-cue-in {
    from { opacity: 0; transform: translate(-7px, -50%); }
    to   { opacity: 1; transform: translate(0, -50%); }
  }
  .hac[data-hac-side="left"] .hac__cue {
    animation-name: hac-cue-in-left;
  }
  @keyframes hac-cue-in-left {
    from { opacity: 0; transform: translate(7px, -50%); }
    to   { opacity: 1; transform: translate(0, -50%); }
  }
}

/* Hover and focus. The chip holds still -- only the glyph leans in, which is
   enough to say the two belong together and little enough not to be a show. */
.hac__trigger:hover .hac__cue,
.hac__trigger:focus-visible .hac__cue {
  border-color: var(--hac-accent);
  color: var(--hac-ink);
  opacity: 1;
}

.hac__trigger:hover .hac__cue svg,
.hac__trigger:focus-visible .hac__cue svg {
  transform: translateX(1.5px);
}

/*
 * Once the visitor has opened the assistant the cue has done its work, so it
 * stops asking: it keeps the label, at a weight that no longer competes with
 * the page, and comes back to full strength under the pointer. The class is set
 * from one flag in localStorage -- the whole of the state this needs.
 *
 * The quieting is mostly the lost shadow rather than the lost opacity, because
 * fading a chip fades its text with it. Measured against this page: at .6 the
 * label came out at 2.9:1 and failed, at .8 it holds 4.5:1. Something that
 * still has to be read cannot be turned down past the point of being readable.
 */
.hac--known .hac__cue {
  opacity: .8;
  box-shadow: none;
  animation: none;
}

/* Open, the panel is the interface and a chip floating beside it is clutter. */
.hac__trigger[aria-expanded="true"] .hac__cue {
  opacity: 0;
  visibility: hidden;
  transition: opacity .16s ease, visibility 0s linear .16s;
}

/* ---- unread badge ---- */

.hac__badge {
  position: absolute;
  top: 6%;
  right: 2%;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--ember, #FF9A4D);
  color: var(--deep, #05080D);
  font-family: var(--hac-mono);
  font-size: 11px;
  font-weight: 600;
  line-height: 20px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--canvas, #0A0E15);
}

.hac__badge[hidden] { display: none; }

/* ------------------------------------------------------------------ panel */

.hac__panel {
  pointer-events: auto;
  width: min(var(--hac-panel-w), calc(100vw - var(--hac-edge) * 2));
  /* The runtime knows how much room the avatar has left above or below itself
     once it can stand anywhere; the second figure is the fallback for before it
     has said, and for a browser running without the script. */
  /*
   * Taller than it was, and never taller than the room the avatar left it. The
   * runtime supplies that room once it knows where the avatar stands; the
   * second figure is for before it has said, and for a browser with no script.
   */
  max-height: min(620px, var(--hac-panel-max, calc(100vh - var(--hac-size) * 1.6 - var(--hac-edge) * 3)));
  /* dvh where it is understood. Declared second so a browser that does not know
     it keeps the vh line above rather than dropping the cap altogether. */
  max-height: min(620px, var(--hac-panel-max, calc(100dvh - var(--hac-size) * 1.6 - var(--hac-edge) * 3)));
  display: flex;
  flex-direction: column;
  /* Only the transcript scrolls. The header and the composer are pinned by
     being flex:none siblings of the one part that flexes. */
  overflow: hidden;
  background: var(--hac-bg);
  border: 1px solid var(--hac-line);
  border-radius: var(--hac-radius);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .55), 0 2px 0 rgba(255, 255, 255, .02) inset;
  color: var(--hac-ink);
  font-family: var(--hac-display);
  /* Opens from the avatar's corner, not from nowhere -- whichever corner that
     has become. */
  transform-origin: var(--hac-panel-origin, 100% 100%);
}

.hac__panel[hidden] { display: none; }

@media (prefers-reduced-motion: no-preference) {
  .hac__panel {
    animation: hac-in .28s cubic-bezier(.22, .68, .36, 1) both;
  }
  @keyframes hac-in {
    from { opacity: 0; transform: translateY(10px) scale(.97); }
    to   { opacity: 1; transform: none; }
  }
}

/* ---- head ---- */

.hac__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 12px 13px 15px;
  border-bottom: 1px solid var(--hac-line);
  flex: none;
}

.hac__mark {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
  background: var(--hac-accent);
  box-shadow: 0 0 0 3px var(--hac-accent-mute);
}

.hac__ident { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.hac__ident strong { font-size: 14px; font-weight: 600; letter-spacing: -.01em; }

.hac__status {
  font-family: var(--hac-mono);
  font-size: 11px;
  color: var(--hac-ink-2);
  letter-spacing: .02em;
}

.hac__close {
  flex: none;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: none;
  color: var(--hac-ink-2);
  cursor: pointer;
}
.hac__close svg { width: 16px; height: 16px; }
.hac__close:hover { color: var(--hac-ink); border-color: var(--hac-line); }

/* ---- transcript ---- */

.hac__log {
  /*
   * `1 1 0` with min-height:0, not `1 1 auto` with a floor.
   *
   * A flex item will not shrink below its automatic minimum, and this one was
   * given an explicit 120px one on top of that. When the row of controls was
   * added, header + controls + composer + that floor came to more than the
   * panel's own max-height -- so the box overflowed, and since the panel clips,
   * what got cut was the last child: the composer and its send button.
   *
   * The transcript is the only part that should give way, so it is the only
   * part allowed to.
   */
  flex: 1 1 auto;
  /*
   * Zero, not 120px, and the basis stays `auto`.
   *
   * A flex item will not shrink below its automatic minimum, and this one was
   * given an explicit 120px floor on top of that. Once the row of controls
   * arrived, header + controls + composer + that floor exceeded the panel's
   * max-height, the box overflowed, and because the panel clips, what got cut
   * was the last child -- the composer and its send button.
   *
   * A basis of 0 fixes the clipping too, and collapses the transcript to
   * nothing whenever the panel is shorter than its cap, because the content no
   * longer contributes to the panel's intrinsic height. `auto` with a zero
   * floor is the pair that wants: it sizes to its content until the panel runs
   * out of room, and is then the only part that gives way.
   */
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
}

.hac__msg {
  max-width: 86%;
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  /* A pasted URL must not widen the panel. */
  overflow-wrap: break-word;
}

.hac__msg--bot {
  align-self: flex-start;
  background: rgba(255, 255, 255, .04);
  border: 1px solid var(--hac-line);
  border-bottom-left-radius: 4px;
}

.hac__msg--you {
  align-self: flex-end;
  background: var(--hac-accent-mute);
  border: 1px solid var(--hac-accent-mute);
  color: var(--hac-ink);
  border-bottom-right-radius: 4px;
}

.hac__msg--bad {
  align-self: stretch;
  max-width: none;
  background: rgba(255, 154, 77, .1);
  border: 1px solid var(--ember, #FF9A4D);
  color: var(--hac-ink);
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}

.hac__msg p { margin: 0; }
.hac__msg p + p { margin-top: .55em; }
.hac__msg a { color: var(--hac-accent-hi); }

.hac__retry {
  font-family: var(--hac-mono);
  font-size: 12px;
  padding: 5px 11px;
  border-radius: 7px;
  border: 1px solid var(--hac-line);
  background: none;
  color: var(--hac-ink);
  cursor: pointer;
}
.hac__retry:hover { border-color: var(--hac-accent); color: var(--hac-accent-hi); }

/* ---- thinking ---- */

.hac__dots { display: inline-flex; gap: 4px; align-items: center; height: 1.5em; }
.hac__dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--hac-ink-2);
  opacity: .45;
}
@media (prefers-reduced-motion: no-preference) {
  .hac__dots i { animation: hac-dot 1.25s ease-in-out infinite; }
  .hac__dots i:nth-child(2) { animation-delay: .16s; }
  .hac__dots i:nth-child(3) { animation-delay: .32s; }
  @keyframes hac-dot {
    0%, 60%, 100% { opacity: .28; transform: translateY(0); }
    30%           { opacity: .95; transform: translateY(-3px); }
  }
}

/* ---- suggested prompts ---- */

.hac__prompts {
  /*
   * Whole chips or none, and never a scrollbar around them.
   *
   * The reasoning this replaces was right about the priority and wrong about
   * the remedy. The chips are 74px, and on a short panel the header, the chips,
   * the control row and the composer come to more than the panel has -- so they
   * were made to shrink and scroll what did not fit. But shrinking a flex item
   * to less than its content is what produces a scrollbar, and this one ended
   * up with the same second scrollbar as the row below it, around four chips.
   * It did not even buy what it was for: at the smallest panel the runtime can
   * hand us the composer was still clipped, scrollbar and all.
   *
   * They are the least important thing on screen once the panel is short, so
   * the honest reading of that is to drop them, not to squeeze them: a chip is
   * a sentence the visitor can type anyway, and half a row of them behind a
   * scrollbar is worth less than the composer they were crowding. showPrompts()
   * takes them back when they do not fit; here they are simply themselves.
   */
  flex: none;
  overflow: visible;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 6px;
  padding: 0 15px 12px;
}
.hac__prompts[hidden] { display: none; }

.hac__prompt {
  font-family: var(--hac-mono);
  font-size: 12px;
  padding: 6px 11px;
  border-radius: 20px;
  border: 1px solid var(--hac-line);
  background: none;
  color: var(--hac-ink-2);
  cursor: pointer;
  transition: color .2s ease, border-color .2s ease;
}
.hac__prompt:hover { color: var(--hac-accent-hi); border-color: var(--hac-accent); }

/* ---- composer ---- */

/* ------------------------------------------------- the way past the assistant */

/*
 * A quiet row above the composer, not a call to action. The assistant is the
 * offer; this is the way past it, and it should read as the smaller of the two
 * without ever being hard to find.
 *
 * Laid out with logical properties throughout, so the row reverses correctly if
 * the panel is ever given dir="rtl" -- the icon leads the text either way.
 */
.hac__aside,
.hac__compose {
	/*
	 * One row, at its own height, never a scroll container.
	 *
	 * These were `flex: 0 1 auto` with `overflow-y: auto`, on the reasoning that
	 * a short panel should scroll the row rather than clip it. That reasoning
	 * gave the panel a second scrollbar, and the way it arrived is worth keeping
	 * written down, because nothing about the state was wrong when it appeared.
	 *
	 * Flex distributes shrinkage across every shrinkable item in proportion to
	 * its base size -- not to the one that has the most to give. So the moment
	 * the panel reached its max-height, this row was squeezed a little too:
	 * 42px of content in 28px of box, and a scrollbar around one button. Going
	 * to Diaa and back is what reliably got there, because that round trip both
	 * lengthens the transcript and, while waiting, makes this row taller.
	 * Returning to the assistant restored the row's contents but not its height,
	 * so the scrollbar stayed -- looking like state left behind when it was only
	 * arithmetic.
	 *
	 * The transcript is the one part that should give way, and `.hac__log` is
	 * already written to: `flex: 1 1 auto` with `min-height: 0`, which lets it
	 * shrink to nothing. It does not need help. Taking this row out of the
	 * shrinking entirely is what leaves the composer safe, not letting it scroll.
	 */
	flex: none;
	overflow: visible;
	border-top: 1px solid var(--hac-line);
	padding: 8px 11px;
}

/*
 * Every control in this row, not just its containers.
 *
 * `.hac__human` sets display:inline-flex, and an author rule beats the user
 * agent's `[hidden] { display: none }` -- so the two buttons went on rendering
 * however carefully the panel set `hidden`, and "Parler avec Diaa" sat next to
 * "Revenir à l'assistant". The state machine was right the whole time; the
 * stylesheet was quietly ignoring it.
 *
 * Listed together so the next control added here inherits the guard instead of
 * rediscovering the bug.
 */
.hac__aside[hidden],
.hac__compose[hidden],
.hac__confirm[hidden],
.hac__human[hidden],
.hac__wait-note[hidden] { display: none; }

.hac__human {
	display: inline-flex;
	align-items: center;
	gap: 7px;
	padding: 6px 9px;
	margin-inline-start: -9px;
	border: 0;
	border-radius: 8px;
	background: none;
	color: var(--hac-ink-2);
	font-family: var(--hac-mono);
	font-size: 12px;
	letter-spacing: .01em;
	cursor: pointer;
	transition: color .2s var(--hac-ease, ease), background .2s var(--hac-ease, ease);
}

.hac__human svg { width: 14px; height: 14px; flex: none; }

.hac__human:hover,
.hac__human:focus-visible {
	color: var(--hac-ink);
	background: var(--hac-accent-mute);
}

.hac__wait-note {
	margin: 0 0 6px;
	color: var(--hac-ink-2);
	font-size: 12.5px;
	line-height: 1.45;
}

/* The way back reads as the quieter of the two: it is an exit, not an offer. */
.hac__human--back { color: var(--hac-ink-2); }

.hac__confirm-lead {
	margin: 0 0 7px;
	color: var(--hac-ink);
	font-size: 12.5px;
}

.hac__confirm-acts {
	margin: 0;
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}

.hac__compose-lead {
	margin: 0 0 6px;
	color: var(--hac-ink-2);
	font-size: 12.5px;
	line-height: 1.45;
}

.hac__compose-back {
	padding: 0;
	border: 0;
	background: none;
	color: var(--hac-accent);
	font-family: var(--hac-mono);
	font-size: 12px;
	cursor: pointer;
	text-decoration: underline;
	text-underline-offset: 3px;
}

.hac__compose-back:hover { color: var(--hac-accent-hi); }

.hac__form {
  flex: none;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 11px;
  border-top: 1px solid var(--hac-line);
}

.hac__input {
  flex: 1;
  min-height: 38px;
  max-height: 116px;
  padding: 9px 11px;
  border: 1px solid var(--hac-line);
  border-radius: 10px;
  background: rgba(0, 0, 0, .22);
  color: var(--hac-ink);
  font-family: var(--hac-display);
  font-size: 14px;
  line-height: 1.45;
  resize: none;
  overflow-y: auto;
}
.hac__input::placeholder { color: var(--hac-ink-2); opacity: .75; }
.hac__input:focus { outline: none; border-color: var(--hac-accent); }

.hac__send {
  flex: none;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--hac-accent);
  border-radius: 10px;
  background: var(--hac-accent);
  color: var(--deep, #05080D);
  cursor: pointer;
  transition: opacity .2s ease;
}
.hac__send svg { width: 18px; height: 18px; }
.hac__send:disabled { opacity: .32; cursor: default; }
.hac__send:not(:disabled):hover { background: var(--hac-accent-hi); border-color: var(--hac-accent-hi); }

/* -------------------------------------------------------------- utilities */

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

.hac :focus-visible {
  outline: 2px solid var(--hac-accent);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ------------------------------------------------------------- dragging */

/*
 * Only where there is a pointer to grab with. A large touch screen is not a
 * mouse, and a phone must keep the position the stylesheet gives it.
 */
@media (min-width: 721px) and (pointer: fine) {
	/*
	 * Addressed through the parent deliberately. The theme resets buttons with
	 * `button:not(:disabled){cursor:pointer}`, and a :not() carrying a
	 * pseudo-class scores (0,1,1) -- which beats a lone class whatever the
	 * order. Two classes clear it honestly.
	 */
	.hac > .hac__trigger { cursor: grab; }
	.hac--dragging > .hac__trigger { cursor: grabbing; }

	/* The avatar is a photograph, and a browser will happily offer to drag it
	   away as an image if not told otherwise. */
	.hac__trigger img { -webkit-user-drag: none; user-select: none; }
}

/*
 * Held only for the length of the gesture, and on the document rather than on
 * the widget: the text being accidentally selected during a drag belongs to the
 * page, not to the avatar.
 */
html.hac-dragging,
html.hac-dragging body {
	user-select: none;
	-webkit-user-select: none;
}

html.hac-dragging * { cursor: grabbing !important; }

/* ------------------------------------------------------------- responsive */

@media (max-width: 720px) {
  .hac {
    --hac-size: 104px;
    --hac-edge: 12px;
  }
  .hac__panel {
    /* On a phone the panel is the interface, so it takes the screen rather than
       floating as a card the thumb has to aim at. */
    position: fixed;
    inset: 0;
    width: 100vw;
    max-height: none;
    border: 0;
    border-radius: 0;
    /* vh first as the floor, then dvh where it is understood: 100vh on a phone
       measures the viewport as if the browser chrome were not there, which
       leaves the composer under the address bar. */
    height: 100vh;
    height: 100dvh;
    /* Nothing here hands a scroll on to the page behind. */
    overscroll-behavior: none;
    /*
     * No scaling on a phone. The card animation opens from 97%, which on a
     * full-screen sheet means a gap down every edge with the site showing
     * through it -- and an animation that stalls, as they do in a background
     * tab, leaves the sheet sitting there inset for good. A sheet that covers
     * the screen has to cover it in every frame.
     */
    transform: none;
  }

  /* Clear of the notch, the status bar and the home indicator. */
  .hac__head {
    padding-top: calc(13px + env(safe-area-inset-top, 0px));
    padding-right: calc(12px + env(safe-area-inset-right, 0px));
    padding-left: calc(15px + env(safe-area-inset-left, 0px));
  }

  .hac__form {
    padding-bottom: calc(11px + env(safe-area-inset-bottom, 0px));
    padding-right: calc(11px + env(safe-area-inset-right, 0px));
    padding-left: calc(11px + env(safe-area-inset-left, 0px));
  }

  .hac__log {
    padding-right: calc(15px + env(safe-area-inset-right, 0px));
    padding-left: calc(15px + env(safe-area-inset-left, 0px));
  }

  .hac__human,
  .hac__compose-back {
    min-height: 44px;
    font-size: 13px;
  }

  .hac__aside,
  .hac__compose {
    padding-inline: calc(11px + env(safe-area-inset-left, 0px)) calc(11px + env(safe-area-inset-right, 0px));
  }

  /* A thumb needs a target, not a cursor's. */
  .hac__close {
    width: 44px;
    height: 44px;
    margin-right: -7px;
  }
  .hac__close svg { width: 20px; height: 20px; }

  .hac__msg { max-width: 92%; }
}

@media (max-width: 720px) and (prefers-reduced-motion: no-preference) {
	.hac__panel { animation: hac-sheet-in .24s ease-out both; }
	@keyframes hac-sheet-in {
		from { opacity: 0; }
		to   { opacity: 1; }
	}
}

/*
 * The scroll lock.
 *
 * Set on <html> while the sheet is open on a phone. The overflow pair alone is
 * what a desktop browser needs; iOS Safari ignores it on <body> often enough
 * that the page still moves under the sheet, so the script additionally pins
 * the body with position:fixed and a negative top, and puts the visitor back
 * where they were on close. Both halves live together so neither can be
 * applied without the other.
 */
html.hac-locked,
html.hac-locked body {
	overflow: hidden;
	overscroll-behavior: none;
}

html.hac-locked body {
	position: fixed;
	width: 100%;
	/* `top` is written by the script: the visitor's own scroll offset, negated,
	   so the page does not jump to the top the moment it is pinned. */
}

/* A short landscape phone has no room for a 92px head plus a panel. */
@media (orientation: landscape) and (max-height: 480px) {
  .hac { --hac-size: 76px; }
}

/* --------------------------------------------------------- reduced motion */

@media (prefers-reduced-motion: reduce) {
  .hac__avatar { transition: none; }
}

/* ------------------------------------------------------------ human handoff */

/*
 * A reply from a person is never dressed as the assistant's. It keeps the
 * panel's language -- same bubble, same type -- and adds one quiet mark of
 * authorship, which is all the distinction it needs.
 */

.hac__msg--human {
  align-self: flex-start;
  background: var(--hac-accent-mute);
  border: 1px solid var(--hac-accent);
  border-bottom-left-radius: 4px;
}

.hac__from {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  font-family: var(--hac-mono);
  font-size: 10.5px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--hac-accent-hi);
}

.hac__from i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--good, #4ED184);
  flex: none;
}

/* The things that happen to a conversation, rather than things said in it. */
.hac__note {
  align-self: center;
  max-width: 92%;
  padding: 6px 12px;
  border-radius: 20px;
  background: rgba(255, 255, 255, .04);
  border: 1px solid var(--hac-line);
  color: var(--hac-ink-2);
  font-family: var(--hac-mono);
  font-size: 11.5px;
  line-height: 1.45;
  text-align: center;
  overflow-wrap: break-word;
}

/* The handoff question's two answers. */
.hac__offer {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-self: flex-start;
  padding: 2px 0 4px;
}

.hac__prompt--yes {
  color: var(--hac-ink);
  border-color: var(--hac-accent);
  background: var(--hac-accent-mute);
}

.hac__prompt--yes:hover {
  color: var(--hac-accent-hi);
}

/* While a person owns the conversation the header light stops being the
   assistant's blue, so the state is legible without reading the words. */
.hac__panel.is-human .hac__mark {
  background: var(--good, #4ED184);
  box-shadow: 0 0 0 3px rgba(78, 209, 132, .16);
}

@media (prefers-reduced-motion: no-preference) {
  .hac__msg--human,
  .hac__note {
    animation: hac-arrive .32s cubic-bezier(.22, .68, .36, 1) both;
  }
  @keyframes hac-arrive {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
  }
}

/*
 * The announcement region. Present for screen readers, absent for everyone
 * else -- clip rather than display:none, which would take it out of the
 * accessibility tree along with everything it has to say.
 */
.hac__live {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	border: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
}
