/* Mini Audrey: the little drawn Audrey in the bottom right corner, and her "ask me" speech bubble.
   The pictures and behaviour are in features/mini-audrey.js. She is drawn in lab/mini-audrey-avatar/avatar.js.
   --ma-u is how many pixels one drawing unit is: she is about 96px tall on a computer and 62px on a phone. */
.ma {
  --ma-u: 0.747px; --ma-right: 63;
  position: fixed; z-index: 40; right: max(6px, env(safe-area-inset-right, 0px)); bottom: calc(env(safe-area-inset-bottom, 0px) - 4px);
  line-height: 0; pointer-events: none; -webkit-tap-highlight-color: transparent;
  translate: 0 calc(var(--ma-lift, 0px) * -1);
  /* --ma-dodge: how far she has stepped up the edge to stay off words and buttons */
  transform: translateY(calc(var(--ma-dodge, 0px) * -1));
  transition: translate 0.55s cubic-bezier(0.3, 1.45, 0.5, 1), transform 0.5s cubic-bezier(0.3, 1.2, 0.5, 1), opacity 0.2s ease, visibility 0s;
}
/* in the footer she rides its top edge, so she follows the page without easing */
.ma.on-foot { transition: transform 0.5s cubic-bezier(0.3, 1.2, 0.5, 1), opacity 0.2s ease, visibility 0s; }
.ma.no-ease { transition: none !important; }
/* before About (the opening), and when there is nothing for her to do, she is off screen */
.ma.is-out { translate: 0 calc(112% + var(--ma-dodge, 0px)); opacity: 0; visibility: hidden; transition: translate 0.3s cubic-bezier(0.5, 0, 0.9, 0.5), opacity 0.2s ease 0.1s, visibility 0s 0.32s; }
/* phones: she slips down while you scroll. Anywhere: she tucks away when there is no spot clear of words */
.ma.is-away, .ma.is-shy { translate: 0 calc(108% + var(--ma-dodge, 0px)); transition: translate 0.24s cubic-bezier(0.5, 0, 0.9, 0.5); }
/* when she is up the edge she leaves and comes back by the side, so she never travels across what you're reading */
.ma.from-side.is-out, .ma.from-side.is-away, .ma.from-side.is-shy { translate: calc(100% + 16px) calc(var(--ma-lift, 0px) * -1); }

.ma-btn {
  position: relative; display: block; margin: 0; padding: 0; border: 0; background: none; color: inherit; font: inherit; line-height: 0;
  -webkit-appearance: none; appearance: none; border-radius: 18px; touch-action: manipulation; pointer-events: none;
}
.ma-btn:focus { outline: none; }
/* keyboard focus: a soft garnet glow around her, not a ruled box */
.ma-btn:focus-visible .ma-img { filter: drop-shadow(0 0 2px #8C2F39) drop-shadow(0 0 6px rgba(140, 47, 57, 0.7)); }
.ma-body { display: block; }

/* ---------- her: one picture per outfit, her closed eyes laid over it, and see-through boxes where she is drawn ---------- */
.ma-fig { position: relative; display: block; width: calc(var(--w) * var(--ma-u)); height: calc(var(--h) * var(--ma-u)); transform-origin: calc(var(--ox) * var(--ma-u)) calc(var(--oy) * var(--ma-u)); will-change: transform; }
.ma-sway { position: absolute; inset: 0; display: block; transform-origin: calc(var(--ox) * var(--ma-u)) calc(var(--oy) * var(--ma-u)); }
.ma-img, .ma-lids { position: absolute; left: calc(var(--ix) * var(--ma-u)); top: calc(var(--iy) * var(--ma-u)); width: calc(126 * var(--ma-u)); height: calc(148 * var(--ma-u)); max-width: none; border: 0; pointer-events: none; user-select: none; -webkit-user-select: none; -webkit-user-drag: none; }
/* a blink: her closed eyes show for a moment */
.ma-lids { opacity: 0; }
.ma.blink .ma-lids { opacity: 1; }
.ma-svg { position: absolute; inset: 0; display: block; width: 100%; height: 100%; overflow: visible; }
/* only the boxes over her take clicks, so the empty space around her never blocks the page */
.ma-svg rect { pointer-events: fill; }
/* the little flash when she takes your picture */
.ma-spark { position: absolute; left: calc((var(--ix) + 51) * var(--ma-u)); top: calc((var(--iy) + 26) * var(--ma-u)); width: calc(22 * var(--ma-u)); height: calc(22 * var(--ma-u)); opacity: 0; transform-origin: 50% 45%; pointer-events: none; overflow: visible; }

/* ---------- small signs of life (never with reduced motion) ---------- */
@media (prefers-reduced-motion: no-preference) {
  /* she sways a little on her feet */
  .ma-sway { animation: ma-sway 4.6s ease-in-out infinite alternate; }
  /* answering: she bobs as she talks */
  .ma.is-talking .ma-sway { animation: ma-talk 0.34s ease-in-out infinite alternate; }
  .ma.snapped .ma-spark { animation: ma-flash 0.42s ease-out both; }
  .ma-ask-a.on span { display: inline-block; animation: ma-word 0.24s ease-out both; animation-delay: calc(var(--i) * 45ms); }
  .ma.show-tag .ma-tag { animation: ma-tag 2.4s ease-in-out 0.5s infinite; }
  @media (hover: hover) { .ma-btn:hover .ma-body { translate: 0 -2px; } }
  .ma-body { transition: translate 0.25s cubic-bezier(0.3, 1.4, 0.5, 1); }
}
/* nothing moves while she is out of sight */
.ma.is-out *, .ma.is-away *, .ma.is-shy *, .ma.is-paused * { animation-play-state: paused !important; }
@keyframes ma-sway { from { transform: rotate(-0.9deg); } to { transform: rotate(0.9deg); } }
@keyframes ma-talk { from { transform: translateY(0) rotate(-1deg); } to { transform: translateY(-1.6px) rotate(1.4deg); } }
@keyframes ma-flash { 0% { opacity: 0; transform: scale(0.5); } 30% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(1.25); } }
@keyframes ma-word { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes ma-tag { 0%, 100% { translate: 0 0; } 50% { translate: 0 -3px; } }

/* No outlines anywhere here (she hates lines): the tag, the bubble and the question pills are told apart
   by soft tints and shadows only. Keyboard focus shows as a soft garnet glow, not a ruled box. */

/* ---------- the "ask me" tag (the first time, and when you point at her) ---------- */
.ma-tag {
  position: absolute; right: calc((var(--ma-right) + 27) * var(--ma-u)); bottom: calc(106 * var(--ma-u));
  padding: 7px 13px 8px; border-radius: 999px; background: #FFFDF8; color: #2A2420;
  box-shadow: 0 1.5px 0 rgba(141, 130, 115, 0.42), 0 7px 16px -5px rgba(26, 20, 16, 0.36);
  font: 600 13px/1 var(--sans, "Hanken Grotesk", system-ui, sans-serif); letter-spacing: 0; white-space: nowrap;
  opacity: 0; visibility: hidden; scale: 0.86; transform-origin: 100% 100%;
  transition: opacity 0.18s ease, scale 0.26s cubic-bezier(0.3, 1.5, 0.5, 1), visibility 0s 0.18s;
}
/* The tag only ever shows beside her head while she stands still in view: the script gives her `tag-ok` then, and
   takes it away the moment she moves, tucks away, leaves or opens the bubble. Without it nothing can show the tag. */
.ma.tag-ok.show-tag .ma-tag, .ma.tag-ok:not(.tag-quiet) .ma-btn:focus-visible .ma-tag { opacity: 1; visibility: visible; scale: 1; transition: opacity 0.18s ease, scale 0.26s cubic-bezier(0.3, 1.5, 0.5, 1), visibility 0s; }
@media (hover: hover) { .ma.tag-ok .ma-btn:hover .ma-tag { opacity: 1; visibility: visible; scale: 1; transition: opacity 0.18s ease, scale 0.26s cubic-bezier(0.3, 1.5, 0.5, 1), visibility 0s; } }
/* and it goes at once, with no fade left hanging in the air */
.ma:not(.tag-ok) .ma-tag, .ma.is-open .ma-tag, .ma.is-out .ma-tag, .ma.is-away .ma-tag, .ma.is-shy .ma-tag { opacity: 0 !important; visibility: hidden !important; scale: 0.86 !important; transition: none !important; animation: none !important; }

/* ---------- the speech bubble: a magnet too (cream, a little thickness, a soft shadow) ---------- */
.ma-ask {
  position: absolute; right: 0; bottom: calc(100% - 2px); width: min(338px, calc(100vw - 16px)); box-sizing: border-box;
  background: #FFFDF8; color: #2A2420; border-radius: 20px;
  box-shadow: 0 2px 0 rgba(141, 130, 115, 0.42), 0 3px 8px rgba(26, 20, 16, 0.1), 0 22px 40px -14px rgba(26, 20, 16, 0.5);
  font-family: var(--sans, "Hanken Grotesk", system-ui, sans-serif); line-height: 1.35; text-align: left; pointer-events: auto;
  transform-origin: calc(100% - var(--ma-right) * var(--ma-u)) calc(100% + 10px); opacity: 0; scale: 0.84; transition: opacity 0.14s ease, scale 0.16s ease-in;
}
.ma-ask[hidden] { display: none; }
.ma-ask.on { opacity: 1; scale: 1; transition: opacity 0.14s ease, scale 0.3s cubic-bezier(0.3, 1.5, 0.5, 1); }
/* the pointer toward her */
.ma-ask::after {
  content: ""; position: absolute; right: max(22px, calc(var(--ma-right) * var(--ma-u) - 9px)); bottom: -8px; width: 17px; height: 17px;
  background: #FFFDF8; box-shadow: 1.5px 1.5px 0 rgba(141, 130, 115, 0.42), 5px 5px 9px -3px rgba(26, 20, 16, 0.28); rotate: 45deg; border-radius: 0 0 4px 0;
}
.ma-ask-in { position: relative; z-index: 1; padding: 16px 16px 15px; max-height: calc(100vh - 170px); max-height: calc(100dvh - 170px); overflow-y: auto; overscroll-behavior: contain; border-radius: 20px; background: #FFFDF8; }
.ma-ask-h { margin: 0 34px 11px 0; font: 400 25px/1 var(--serif, "Instrument Serif", Georgia, serif); color: #2A2420; }
.ma-ask-x {
  position: absolute; top: 9px; right: 9px; width: 30px; height: 30px; display: grid; place-items: center; margin: 0; padding: 0;
  border: 0; border-radius: 50%; background: none; color: #6A6058; -webkit-appearance: none; appearance: none;
}
.ma-ask-x:hover { background: rgba(42, 36, 32, 0.07); color: #2A2420; }
.ma-ask-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.ma-ask-chips li { margin: 0; padding: 0; }
.ma-ask-chips li::before { content: none; }
/* the questions: filled pills */
.ma-chip {
  display: block; margin: 0; padding: 7px 12px 8px; border: 0; border-radius: 999px; background: #F1E8D8; color: #2A2420;
  font: 500 14.5px/1.25 var(--sans, "Hanken Grotesk", system-ui, sans-serif); text-align: left; -webkit-appearance: none; appearance: none;
  transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
@media (hover: hover) { .ma-chip:hover { background: #E8DCC7; } }
.ma-chip[aria-pressed="true"] { background: #2A2420; color: #FFFDF8; }
.ma-chip:focus, .ma-ask-x:focus { outline: none; }
/* (the site's own focus rule squares the corners and draws a ruled box, so both are set back here) */
.ma-chip:focus-visible { border-radius: 999px; box-shadow: 0 0 0 3px rgba(140, 47, 57, 0.4); }
.ma-ask-x:focus-visible { border-radius: 50%; box-shadow: 0 0 0 3px rgba(140, 47, 57, 0.4); }
/* her answer: set apart by the site's soft gold, not a rule */
.ma-ask-a { margin: 12px 0 0; padding: 11px 13px 12px; border-radius: 13px; background: #F8EBCB; color: #2A2420; font-size: 16.5px; font-weight: 500; line-height: 1.4; }
.ma-ask-a:empty { display: none; }

/* ---------- for other pages (My World): her picture and her questions without the corner widget ---------- */
.ma-stand { position: relative; display: inline-block; line-height: 0; vertical-align: bottom; }
.ma-stand.blink .ma-lids { opacity: 1; }
.ma-ask-inline { max-height: none; overflow: visible; color: #2A2420; font-family: var(--sans, "Hanken Grotesk", system-ui, sans-serif); line-height: 1.35; text-align: left;
  box-shadow: 0 2px 0 rgba(141, 130, 115, 0.42), 0 3px 8px rgba(26, 20, 16, 0.1), 0 22px 40px -14px rgba(26, 20, 16, 0.4); }
.ma-ask-inline .ma-ask-h { margin-right: 0; }

@media (max-width: 640px) {
  .ma { --ma-u: 0.4825px; right: max(2px, env(safe-area-inset-right, 0px)); }
  .ma-tag { font-size: 12px; padding: 6px 11px 7px; }
  .ma-ask { width: min(338px, calc(100vw - 12px)); }
  .ma-ask-in { padding: 14px 14px 13px; }
  .ma-chip { font-size: 14px; }
}
@media print { .ma { display: none !important; } }
