/* From the voice note to its transcript: the chat of an invented AI notes app on a soft grey page. The voice bubble
   is a button; its bars live in a layer of their own (.bubble__bars), pinned to the bubble's top right corner like
   the transcript, so while the bubble grows on its spring to the left and down, the lines never move with it. */
:root {
  --page: #eceef2;          /* the page */
  --page-2: #f7f8fa;        /* the light at the top of the page */
  --panel: #ffffff;         /* the chat */
  --ink: #16171c;           /* the words */
  --muted: #8a8e99;         /* the small words */
  --line: rgba(22, 24, 34, 0.07); /* thin rules */
  --ai: #f1f2f5;            /* Mira's bubble */
  --accent: #4f55f1;        /* the voice bubble */
  --accent-2: #7457f4;      /* the other end of its gradient */
  --on-accent: #ffffff;     /* the bars and the words on it */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

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

body {
  min-height: 100svh;
  background: radial-gradient(120% 90% at 50% 0%, var(--page-2), var(--page) 62%);
  color: var(--ink);
  font-family: 'Geist 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 {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 14px;
  overflow: hidden;
}

/* the chat panel */
.chat {
  position: relative;
  width: min(90vw, 340px);
  height: min(384px, calc(100svh - 28px));
  display: flex;
  flex-direction: column;
  border-radius: 26px;
  background: var(--panel);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 0 0 1px rgba(22, 24, 34, 0.06),
    0 2px 4px rgba(22, 24, 34, 0.04),
    0 18px 40px -20px rgba(22, 24, 44, 0.28),
    0 50px 90px -46px rgba(48, 52, 120, 0.3);
  opacity: 0;
}

.chat__head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: clamp(10px, 3.2vh, 14px) 16px clamp(9px, 2.8vh, 12px);
  border-bottom: 1px solid var(--line);
}

.chat__avatar {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: linear-gradient(150deg, var(--accent-2), var(--accent));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 4px 10px -4px rgba(79, 85, 241, 0.6);
}

.chat__avatar svg {
  width: 15px;
  height: 15px;
  fill: #ffffff;
}

.chat__who {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.chat__name {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.chat__sub {
  font-size: 11.5px;
  color: var(--muted);
}

.chat__log {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: clamp(8px, 2.6vh, 14px);
  padding: clamp(10px, 3.4vh, 16px) 14px 8px;
}

.msg {
  align-self: flex-start;
  max-width: 80%;
  margin: 0;
  padding: 9px 12px 10px;
  border-radius: 18px 18px 18px 6px;
  background: var(--ai);
  font-size: 13.5px;
  line-height: 1.42;
  letter-spacing: -0.005em;
}

.voice {
  align-self: flex-end;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

/* the voice bubble: its size is set by the script, the row, the bars and the text are pinned to its top right */
.bubble {
  position: relative;
  display: block;
  margin: 0;
  padding: 0;
  border: 0;
  font: inherit;
  color: var(--on-accent);
  cursor: pointer;
  border-radius: 24px 24px 7px 24px;
  background: linear-gradient(160deg, #5c62ff 0%, var(--accent) 48%, var(--accent-2) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.3),
    inset 0 -1px 0 rgba(20, 10, 80, 0.16),
    0 6px 14px -7px rgba(79, 85, 241, 0.6),
    0 16px 30px -16px rgba(79, 85, 241, 0.45);
  transition: box-shadow 0.3s ease;
  -webkit-tap-highlight-color: transparent;
  transform-origin: 100% 100%;
}

/* a soft sheen in the top left corner, like light on lacquer */
.bubble::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(120% 90% at 0% 0%, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0) 55%);
  pointer-events: none;
}

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

@media (hover: hover) {
  .bubble:hover {
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.34),
      inset 0 -1px 0 rgba(20, 10, 80, 0.16),
      0 8px 18px -8px rgba(79, 85, 241, 0.7),
      0 22px 38px -18px rgba(79, 85, 241, 0.5);
  }
}

.bubble__row {
  position: absolute;
  right: 0;
  top: 0;
  height: 48px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px 0 7px;
  white-space: nowrap;
}

.bubble__play {
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #ffffff;
  box-shadow: 0 2px 6px -2px rgba(20, 10, 80, 0.4), inset 0 -1px 0 rgba(20, 10, 80, 0.08);
}

.bubble__play svg {
  width: 14px;
  height: 14px;
  margin-left: 2px;
  fill: var(--accent);
}

.bubble__wave {
  display: block;
  height: 26px;
  flex: none;
}

.bubble__time {
  font-size: 11.5px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: rgba(255, 255, 255, 0.82);
  min-width: 26px;
}

/* the bars: a zero-sized layer at the top right corner; every bar is placed with x and y from there */
.bubble__bars {
  position: absolute;
  right: 0;
  top: 0;
  width: 0;
  height: 0;
  z-index: 1;
  pointer-events: none;
}

.bar {
  position: absolute;
  left: 0;
  top: 0;
  border-radius: 999px;
}

.bar__i {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: var(--on-accent);
  transform-origin: 50% 50%;
}

.bubble__text {
  position: absolute;
  right: 14px;
  top: 11px;
  z-index: 2;
  display: block;
  margin: 0;
  text-align: left;
  font-size: 13.5px;
  line-height: 1.42;
  letter-spacing: -0.005em;
  visibility: hidden;
}

.word {
  display: inline-block;
  opacity: 0;
}

/* the row under the bubble: the hint at rest, the note and Back once transcribed */
.voice__meta {
  position: relative;
  height: 24px;
  width: 190px;
}

.meta__hint,
.meta__done {
  position: absolute;
  right: 2px;
  top: 0;
  height: 24px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
}

.meta__hint svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
}

.meta__done {
  right: 0;
  gap: 8px;
  visibility: hidden;
}

.meta__back {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 24px;
  margin: 0;
  padding: 0 10px 0 6px;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-size: 11.5px;
  font-weight: 550;
  color: var(--ink);
  background: #ffffff;
  box-shadow: 0 0 0 1px rgba(22, 24, 34, 0.09), 0 2px 5px -2px rgba(22, 24, 34, 0.16);
  cursor: pointer;
  transition: box-shadow 0.25s ease;
  -webkit-tap-highlight-color: transparent;
}

.meta__back svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

@media (hover: hover) {
  .meta__back:hover {
    box-shadow: 0 0 0 1px rgba(22, 24, 34, 0.14), 0 4px 10px -3px rgba(22, 24, 34, 0.2);
  }
}

/* the composer at the bottom */
.chat__composer {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 10px 10px;
  padding: 5px 5px 5px 14px;
  height: 42px;
  border-radius: 999px;
  background: #fafbfc;
  box-shadow: inset 0 0 0 1px rgba(22, 24, 34, 0.08);
}

.composer__field {
  flex: 1;
  font-size: 13px;
  color: #a4a8b2;
  white-space: nowrap;
  overflow: hidden;
}

.composer__mic,
.composer__send {
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
}

.composer__mic svg,
.composer__send svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.composer__mic svg {
  stroke: var(--muted);
}

.composer__send {
  background: var(--ink);
}

.composer__send svg {
  stroke: #ffffff;
}

/* one band of light that crosses the bubble once, when the transcript has landed */
.bubble__sheen {
  --sx: -40%;
  position: absolute;
  inset: 0;
  z-index: 3;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(105deg, rgba(255, 255, 255, 0) calc(var(--sx) - 22%), rgba(255, 255, 255, 0.2) var(--sx), rgba(255, 255, 255, 0) calc(var(--sx) + 22%));
}
