/* Pond web client. docs/design.md: white, one slate-blue ink, no gradients,
   no cards, no emoji. Phone width first; on a laptop the page is a 430 px column. */

:root {
  --ink: #3b5b7a;
  --ink-rgb: 59, 91, 122;
  --text: #1c242c;
  --grey: #8a95a1;
  --line: #e7ebef;
  --bg: #ffffff;
  --quiet: 7.5s;
  --talking: 3.2s;
  --cycle: var(--quiet);
  --avatar: 52px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
[hidden] { display: none !important; }

#app {
  position: relative;
  max-width: 430px;
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
}
.view, .sheet {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

/* Top bar, ~8%: 44 px touch targets either side, title centred. */
.bar {
  flex: 0 0 auto;
  height: max(8dvh, 52px);
  display: grid;
  grid-template-columns: 56px 1fr 56px;
  align-items: center;
  padding: 0 4px;
}
.bar-title {
  margin: 0;
  text-align: center;
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bar-slot { width: 44px; }
.icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  justify-self: center;
  border-radius: 50%;
}
.icon svg { width: 22px; height: 22px; fill: none; stroke: var(--ink); stroke-width: 1.5; }
.icon:focus-visible, .outlined:focus-visible, .room-row:focus-visible, .avatar:focus-visible {
  outline: 2px solid rgba(var(--ink-rgb), .5);
  outline-offset: 2px;
}
.text-button { color: var(--ink); font-weight: 500; height: 44px; padding: 0 8px; justify-self: end; }

.outlined {
  height: 44px;
  padding: 0 22px;
  border: 1px solid rgba(var(--ink-rgb), .55);
  border-radius: 22px;
  color: var(--ink);
  font-weight: 500;
}

/* --- identity ---------------------------------------------------------- */

.identity {
  margin: auto 0;
  padding: 0 32px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.identity label { font-size: 17px; font-weight: 500; }
.identity input {
  font: inherit;
  font-size: 17px;
  padding: 10px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  outline: none;
  background: transparent;
}
.identity input:focus { border-bottom-color: var(--ink); }
.identity .outlined { align-self: flex-start; }
.identity .identity { padding: 0; margin: 0; }
.identity-title { font-size: 28px; font-weight: 600; margin: 0 0 8px; }
.identity-actions { display: flex; align-items: center; gap: 16px; }
#signin-view .identity, #password-view .identity { max-width: 420px; width: 100%; align-self: center; }
#password-view { overflow-y: auto; }
#password-view .identity { padding-top: 32px; padding-bottom: 32px; }
.hint { color: var(--grey); font-size: 13px; margin: 0; }

/* --- rooms ------------------------------------------------------------- */

.room-list { list-style: none; margin: 0; padding: 0 20px; overflow-y: auto; flex: 1 1 auto; }
.room-row {
  width: 100%;
  display: grid;
  grid-template-columns: 36px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
}
.room-text { min-width: 0; }
.room-name { font-size: 17px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-status { color: var(--grey); font-size: 13px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chips { display: flex; }
.chip {
  width: 24px;
  height: 24px;
  margin-left: -6px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 11px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid rgba(var(--ink-rgb), .35);
}
.chip.present { border-color: var(--ink); }
.chip.more { color: var(--grey); border-color: var(--line); }
.empty { color: var(--grey); text-align: center; margin: 40px 0 0; }
.rooms-foot { flex: 0 0 auto; display: flex; justify-content: center; padding: 20px 0 28px; }

/* The ring mark: three rings, rippling only when the room is occupied. */
.mark { position: relative; width: 36px; height: 36px; }
.mark i {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1.2px solid rgba(var(--ink-rgb), .5);
  transform: scale(var(--s));
}
.mark i:nth-child(1) { --s: .3; }
.mark i:nth-child(2) { --s: .62; opacity: .7; }
.mark i:nth-child(3) { --s: .95; opacity: .4; }
.mark.live i { animation: ripple 3.2s linear infinite; opacity: 0; }
.mark.live i:nth-child(2) { animation-delay: -1.07s; }
.mark.live i:nth-child(3) { animation-delay: -2.13s; }

/* --- room -------------------------------------------------------------- */

/* Middle, ~70%: the rings and nothing else, ever. */
.pond { position: relative; flex: 1 1 auto; display: grid; place-items: center; min-height: 0; }
.rings { position: relative; width: min(86%, 56dvh); aspect-ratio: 1; transition: opacity .6s; }
.ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1.4px solid rgba(var(--ink-rgb), .7);
  opacity: 0;
  transform: scale(.06);
  animation: ripple var(--cycle) linear infinite;
}
/* Alternate sharp and slightly blurred: the water feel. */
.ring:nth-child(even) { border-width: 3px; border-color: rgba(var(--ink-rgb), .38); filter: blur(2.2px); }
.ring:nth-child(2) { animation-delay: calc(var(--cycle) * -.2); }
.ring:nth-child(3) { animation-delay: calc(var(--cycle) * -.4); }
.ring:nth-child(4) { animation-delay: calc(var(--cycle) * -.6); }
.ring:nth-child(5) { animation-delay: calc(var(--cycle) * -.8); }
.drop {
  position: absolute;
  inset: 45.5%;
  border-radius: 50%;
  background: rgba(var(--ink-rgb), .2);
  filter: blur(5px);
  animation: breathe var(--cycle) ease-in-out infinite;
}
@keyframes ripple {
  0%   { transform: scale(.06); opacity: 0; }
  10%  { opacity: .9; }
  100% { transform: scale(1); opacity: 0; }
}
@keyframes breathe {
  0%, 100% { transform: scale(1); opacity: .8; }
  50%      { transform: scale(1.35); opacity: 1; }
}
.rings.dim { opacity: .35; }

.overlay {
  position: absolute;
  inset: 0;
  margin: auto;
  width: max-content;
  height: 44px;
  padding: 0 18px;
  color: var(--grey);
  font-size: 13px;
  cursor: default;
}
.overlay.actionable { color: var(--ink); cursor: pointer; }

/* Captions: one line, newest only; the grey second line is reserved for the
   translation and unused in the POC. */
.captions {
  flex: 0 0 auto;
  padding: 0 24px;
  min-height: 58px;
  text-align: center;
  cursor: pointer;
  touch-action: pan-x;
  outline: none;
}
.caption-line {
  margin: 0;
  font-size: 15px;
  min-height: 21px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  transition: opacity .8s, color .2s;
}
.caption-line.status, .caption-line.interim { color: var(--grey); }
.caption-line.final { color: var(--text); }
.caption-line.fading { opacity: 0; }
.caption-line.second { color: var(--grey); font-size: 13px; min-height: 18px; }

/* Bottom, ~20%: the avatar row. */
.avatars {
  flex: 0 0 auto;
  min-height: 20dvh;
  display: flex;
  gap: 14px;
  align-items: flex-start;
  justify-content: safe center;
  padding: 10px 20px 18px;
  overflow-x: auto;
  scrollbar-width: none;
}
.avatars::-webkit-scrollbar { display: none; }
.avatar {
  flex: 0 0 auto;
  width: var(--avatar);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  transition: opacity .3s;
}
.avatar.absent { opacity: .35; }
.face {
  position: relative;
  width: var(--avatar);
  height: var(--avatar);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 19px;
  color: var(--ink);
  border: 1px solid rgba(var(--ink-rgb), .45);
  transition: box-shadow .15s;
}
.avatar.speaking .face { box-shadow: 0 0 0 3px var(--bg), 0 0 0 4.2px var(--ink); }
.avatar-name {
  max-width: calc(var(--avatar) + 14px);
  font-size: 11px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.avatar.speaking .avatar-name { font-weight: 700; }
.avatar.me { cursor: pointer; }
/* Muted: a slash across the initial. */
.avatar.muted .face::after {
  content: "";
  position: absolute;
  width: 26px;
  height: 1.5px;
  background: var(--ink);
  transform: rotate(-45deg);
}
/* The agent: a dashed circle and a dot, filled while active or pressed. */
.avatar.agent .face { border-style: dashed; border-color: rgba(var(--ink-rgb), .7); cursor: pointer; }
.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1.4px solid var(--ink);
  transition: background .15s;
}
.avatar.agent.active .dot, .avatar.agent.pressing .dot { background: var(--ink); }
.avatar.agent.speaking .face { border-style: solid; }

/* --- room settings ----------------------------------------------------- */

.title-button { font: inherit; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-height: 44px; padding: 0 6px; }
.text-button.start { justify-self: start; }
.settings { display: flex; flex-direction: column; gap: 8px; padding: 8px 20px 24px; overflow-y: auto; }
.settings label { font-size: 13px; color: var(--grey); margin-top: 14px; }
.settings input, .settings textarea {
  font: inherit;
  font-size: 16px; /* 16 px stops iOS zooming on focus */
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  resize: vertical;
}
.settings input:focus, .settings textarea:focus { border-color: var(--ink); }
.settings input[aria-invalid="true"] { border-color: #b4483c; }
.field-error { margin: 0; color: #b4483c; font-size: 13px; }
.text-button.danger { color: #b4483c; align-self: flex-start; margin-top: 18px; padding: 0; }

/* --- people: members, friends ----------------------------------------- */

.people { list-style: none; margin: 0; padding: 0; }
.people li {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.people .face {
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center;
  border: 1px solid var(--line); font-size: 14px; font-weight: 500;
}
.people .who { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.people .handle { color: var(--grey); font-size: 13px; margin-left: 6px; }
.people .text-button { height: 32px; }
.people input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--ink); }
.inline-field { display: flex; gap: 10px; align-items: center; }
.inline-field input { flex: 1 1 auto; min-width: 0; }
#friend-me { margin-top: 6px; }

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

.sheet { z-index: 5; }
.transcript { list-style: none; margin: 0; padding: 0 20px 24px; overflow-y: auto; flex: 1 1 auto; }
.transcript li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.transcript .who { font-weight: 500; font-size: 13px; }
.transcript time { color: var(--grey); font-size: 12px; margin-left: 6px; }
.transcript .said { margin-top: 2px; }
.transcript .empty { border: 0; }

/* --- profile menu ------------------------------------------------------ */

.menu {
  position: absolute;
  z-index: 10;
  top: calc(env(safe-area-inset-top) + max(8dvh, 52px) - 4px);
  right: 12px;
  min-width: 200px;
  padding: 12px 0 6px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 6px 24px rgba(28, 36, 44, .08);
}
.menu-name { margin: 0 16px; font-weight: 500; }
.menu-via { margin: 2px 16px 8px; color: var(--grey); font-size: 12px; }
.menu-item { display: block; width: 100%; text-align: left; padding: 10px 16px; color: var(--ink); }
.menu-item:hover { background: rgba(var(--ink-rgb), .05); }

/* Reduced motion: the rings become still concentric circles. */
@media (prefers-reduced-motion: reduce) {
  .ring, .drop, .mark.live i { animation: none; }
  .ring { opacity: .5; }
  .ring:nth-child(1) { transform: scale(.2); }
  .ring:nth-child(2) { transform: scale(.4); }
  .ring:nth-child(3) { transform: scale(.6); }
  .ring:nth-child(4) { transform: scale(.8); }
  .ring:nth-child(5) { transform: scale(1); opacity: .3; }
  .mark.live i { opacity: 1; }
  .caption-line { transition: none; }
}
