/* Video calls (public/facetime.js). The faces are the picture: video runs edge to edge on black, and everything laid
   over it is cut from the letterboard's felt (name plates in board letters, the title plate, the control bar), so a
   call still looks like this room. Green and red mean answer and end, nothing else. Talking = a periwinkle frame that
   thickens with the voice. See DESIGN.md. */
.ft, .fti, .ftp, .ftb { --answer: #2fb36b; --hang: #d93a3a; --talk: #7c8cff; }

/* ---------- the call ---------- */
.ft { position: fixed; left: 0; right: 0; top: 0; height: var(--app-h); z-index: 8000; background: #000; color: var(--letter); opacity: 0; transition: opacity .18s; overscroll-behavior: contain; overflow: hidden; }
.ft.in { opacity: 1; }
.ft.min { visibility: hidden; pointer-events: none; opacity: 0; } /* still playing: hidden, never removed */
body.ft-on .toast { z-index: 8200; }

.ft-stage { position: absolute; left: 0; right: 0; top: 0; bottom: calc(92px + env(safe-area-inset-bottom)); display: grid; gap: 6px; padding: 0; }
.ft-stage.grid { padding: calc(64px + env(safe-area-inset-top)) max(6px, env(safe-area-inset-right)) 6px max(6px, env(safe-area-inset-left));
  grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); grid-template-rows: repeat(var(--rows, 2), minmax(0, 1fr)); }
.ft-stage.grid.odd > .ft-tile:last-child { grid-column: 1 / -1; }
.ft-stage.calling, .ft-stage.duo { display: block; }

.ft-tile { position: relative; overflow: hidden; background-color: var(--felt); background-image: radial-gradient(circle, var(--felt-groove) 1.3px, transparent 1.8px); background-size: 11px 11px; --lv: 0; }
.ft-stage.grid > .ft-tile { border-radius: 14px; }
.ft-stage.calling > .ft-tile, .ft-stage.duo > .ft-tile { position: absolute; inset: 0; }
/* one other person: they fill the screen, you sit in the corner above the bar (tap it to swap) */
.ft-stage.duo > .ft-tile:last-child, .ft-stage.duo.swap > .ft-tile:first-child { inset: auto max(12px, env(safe-area-inset-right)) 12px auto; width: min(30vw, 132px); height: min(40vw, 176px); z-index: 2; border-radius: 14px; box-shadow: 0 0 0 3px var(--letter); cursor: pointer; }
.ft-stage.duo.swap > .ft-tile:last-child { inset: 0; width: auto; height: auto; z-index: 1; border-radius: 0; box-shadow: none; cursor: default; }
.ft-tile video, .ft-tile .ft-relay { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: none; background: #000; }
.ft-tile.vid video, .ft-tile.relayed .ft-relay { display: block; }
.ft-tile.mirror video { transform: scaleX(-1); }
.ft-face { position: absolute; left: 50%; top: 50%; width: min(44%, 150px); aspect-ratio: 1; transform: translate(-50%, -54%); border-radius: 50%; background: #e6e9f7; overflow: hidden; box-shadow: 0 0 0 4px var(--felt), 0 0 0 6px #f5f5f233; }
.ft-face .mface, .ft-face img, .ft-face svg { display: block; width: 100%; height: 100%; }
.ft-stage.duo > .ft-tile:last-child .ft-face, .ft-stage.duo.swap > .ft-tile:first-child .ft-face { width: 64%; box-shadow: none; }
.ft-tile.vid .ft-face, .ft-tile.relayed .ft-face { display: none; }
.ft-tile.ringing .ft-face { animation: ft-ringing 1.6s ease-in-out infinite; }
@keyframes ft-ringing { 50% { box-shadow: 0 0 0 4px var(--felt), 0 0 0 12px #7c8cff66; } }
.ft-tile::after { content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; box-shadow: inset 0 0 0 calc(var(--lv) * 6px + 2px) var(--talk); opacity: 0; transition: opacity .12s; }
.ft-tile.talking::after { opacity: 1; }

/* name plates: a strip of the letterboard */
.ft-tag { position: absolute; left: 8px; bottom: 8px; max-width: calc(100% - 16px); display: flex; align-items: center; gap: 5px; padding: 4px 9px 3px; border-radius: 4px;
  background: var(--felt); color: var(--letter); font: 600 15px/1.1 var(--board); letter-spacing: .12em; text-transform: uppercase; text-shadow: 0 1px 0 #000a; z-index: 1; }
.ft-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ft-mic { display: none; flex: none; width: 15px; height: 15px; }
.ft-mic svg { display: block; width: 100%; height: 100%; fill: #ff8f8f; }
.ft-tile.muted .ft-mic { display: block; }
.ft-stage.duo > .ft-tile:last-child .ft-tag, .ft-stage.duo.swap > .ft-tile:first-child .ft-tag { display: none; }
.ft-stage.duo.swap > .ft-tile:last-child .ft-tag { display: flex; }
.ft-state { position: absolute; left: 0; right: 0; top: calc(50% + min(22%, 75px) + 6px); text-align: center; font-size: 15px; font-weight: 700; color: var(--letter); opacity: .8; }
.ft-state:empty, .ft-tile.vid .ft-state, .ft-tile.relayed .ft-state { display: none; }

/* calling: your own camera behind the faces being rung */
.ft-calling { position: absolute; left: 0; right: 0; top: calc(92px + env(safe-area-inset-top)); z-index: 3; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 0 20px; text-align: center; pointer-events: none; }
.ft-ringing { display: flex; justify-content: center; }
.ft-rface { width: 76px; height: 76px; margin: 0 -9px; border-radius: 50%; background: #e6e9f7; overflow: hidden; box-shadow: 0 0 0 3px var(--felt); animation: ft-rring 1.6s ease-in-out infinite; }
.ft-rface .mface, .ft-rface img, .ft-rface svg { display: block; width: 100%; height: 100%; }
@keyframes ft-rring { 50% { box-shadow: 0 0 0 3px var(--felt), 0 0 0 9px #7c8cff88; } }
.ft-callname { display: inline-block; max-width: 100%; margin-top: 6px; padding: 7px 14px 5px; border-radius: 4px; background: var(--felt); font: 600 28px/1 var(--board); letter-spacing: .14em; text-transform: uppercase; text-shadow: 0 1px 0 #000a; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ft-callline { padding: 3px 10px; border-radius: 4px; background: #000a; font-size: 16px; font-weight: 700; }

/* the title plate */
.ft-top { position: absolute; left: max(10px, env(safe-area-inset-left)); top: calc(8px + env(safe-area-inset-top)); z-index: 4; display: flex; align-items: center; gap: 2px; max-width: calc(100% - 20px); padding: 2px 14px 2px 2px; border-radius: 10px;
  background: var(--felt); color: var(--letter); }
.ft-back { flex: none; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 8px; background: none; color: var(--letter); display: grid; place-items: center; }
.ft-back svg { width: 24px; height: 24px; fill: currentColor; }
.ft-title { min-width: 0; display: flex; align-items: baseline; gap: 10px; font: 600 18px/1 var(--board); letter-spacing: .12em; text-transform: uppercase; text-shadow: 0 1px 0 #000a; }
.ft-who { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ft-clock { flex: none; font-variant-numeric: tabular-nums; opacity: .7; }
.ft-clock:empty { display: none; }

/* the control bar */
.ft-bar { position: absolute; left: 0; right: 0; bottom: 0; z-index: 4; display: flex; justify-content: center; gap: clamp(6px, 3vw, 22px); padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
  background-color: var(--felt); background-image: repeating-linear-gradient(to bottom, transparent 0 7px, var(--felt-groove) 7px 9px); }
.ft-btn { flex: none; width: 60px; display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 0; border: 0; background: none; color: var(--letter); font: 700 12px/1 var(--font); }
.ft-btn svg { box-sizing: content-box; width: 24px; height: 24px; padding: 13px; border-radius: 50%; border: 2px solid var(--letter); fill: currentColor; background: var(--felt); }
.ft-btn.off svg, .ft-btn.on svg { background: var(--letter); fill: var(--felt); }
.ft-btn.end svg { background: var(--hang); border-color: var(--hang); fill: #fff; }
.ft-btn:disabled { opacity: .4; }
.ft-btn:active:not(:disabled) svg { transform: translateY(1px); }

/* add people: a sheet over the bar */
.ft-add { position: absolute; left: 0; right: 0; bottom: calc(92px + env(safe-area-inset-bottom)); z-index: 5; max-height: 60%; overflow-y: auto; max-width: 560px; margin: 0 auto; padding: 6px 16px 10px; border-radius: 20px 20px 0 0;
  background: var(--wall-2); color: var(--ink); }
.ft-addhead { display: flex; align-items: center; justify-content: space-between; min-height: 48px; font-weight: 700; font-size: 17px; }
.ft-addx { width: 44px; height: 44px; padding: 0; border: 0; background: none; color: var(--ink); display: grid; place-items: center; transform: rotate(-90deg); }
.ft-addx svg { width: 22px; height: 22px; fill: currentColor; }
.ft-addrow { display: flex; align-items: center; gap: 12px; min-height: 60px; border-top: 1px solid var(--rule); }
.ft-ring { flex: none; min-height: 38px; padding: 0 18px; border: 0; border-radius: 10px; background: var(--answer); color: #fff; font: 700 15px/1 var(--font); }
.ft-ring:disabled { background: var(--rule); color: var(--ink-2); }

/* ---------- the strip in the chat while a call runs behind ---------- */
.ftb { flex: none; display: flex; align-items: center; gap: 10px; min-height: 50px; padding: 4px 12px 10px 18px; font-size: 15px; letter-spacing: .12em; }
.ftb[hidden] { display: none; }
.ftb-lamp { flex: none; display: inline-grid; place-items: center; height: 24px; padding: 0 8px; border-radius: 5px; font: 600 14px/1 var(--board); letter-spacing: .16em; text-transform: uppercase; white-space: nowrap;
  background: var(--answer); color: #f2fff7; text-shadow: none; box-shadow: inset 0 0 0 1.5px #ffffff40; }
.ftb-who { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0; border: 0; background: none; color: inherit; font: inherit; letter-spacing: inherit; text-transform: inherit; text-shadow: inherit; text-align: left; }
.ftb-faces { flex: none; display: flex; }
.ftb-faces:empty { display: none; }
.ftb-mini { width: 28px; height: 28px; margin-right: -8px; border-radius: 50%; background: #e6e9f7; border: 2px solid var(--felt); overflow: hidden; }
.ftb-mini:last-child { margin-right: 0; }
.ftb-mini .mface, .ftb-mini img, .ftb-mini svg { display: block; width: 100%; height: 100%; }
.ftb-txt { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: .9; }
.ftb-clock { flex: none; font-variant-numeric: tabular-nums; opacity: .7; }
.ftb-end { flex: none; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 50%; background: var(--hang); color: #fff; display: grid; place-items: center; }
.ftb-end svg { width: 22px; height: 22px; fill: currentColor; }
@media (max-width: 360px) { .ftb { gap: 8px; padding-left: 12px; } .ftb-lamp { display: none; } }

/* ---------- incoming ---------- */
.fti { position: fixed; left: 0; right: 0; top: 0; height: var(--app-h); z-index: 8100; display: flex; flex-direction: column; align-items: center; justify-content: space-between; text-align: center; color: var(--letter); opacity: 0; transition: opacity .18s; overscroll-behavior: contain;
  padding: calc(48px + env(safe-area-inset-top)) 20px calc(34px + env(safe-area-inset-bottom));
  background-color: var(--felt); background-image: radial-gradient(circle, var(--felt-groove) 1.3px, transparent 1.8px); background-size: 11px 11px; }
.fti.in { opacity: 1; }
.fti-top { max-width: 100%; }
.fti-kind { font: 600 16px/1 var(--board); letter-spacing: .3em; text-indent: .3em; text-transform: uppercase; opacity: .78; }
.fti-name { margin-top: 14px; max-width: 100%; font: 600 min(64px, 15vw)/1 var(--board); letter-spacing: .12em; text-transform: uppercase; text-shadow: 0 2px 0 #000a; overflow-wrap: anywhere; }
.fti-with { margin-top: 12px; font-size: 17px; opacity: .8; }
.fti-head { position: relative; width: 168px; height: 168px; display: grid; place-items: center; }
.fti-face { position: relative; width: 100%; height: 100%; border-radius: 50%; background: #e6e9f7; overflow: hidden; box-shadow: 0 0 0 4px var(--letter); }
.fti-face .mface, .fti-face img, .fti-face svg { display: block; width: 100%; height: 100%; }
.fti-wave { position: absolute; inset: 0; border-radius: 50%; border: 3px solid var(--talk); animation: fti-wave 2s ease-out infinite; }
.fti-wave.two { animation-delay: 1s; }
@keyframes fti-wave { from { transform: scale(1); opacity: .9; } to { transform: scale(1.7); opacity: 0; } }
.fti-foot { display: flex; justify-content: center; gap: min(96px, 22vw); width: 100%; }
.fti-btn { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 0; border: 0; background: none; color: var(--letter); font: 700 15px/1.1 var(--font); max-width: 110px; }
.fti-btn svg { box-sizing: content-box; width: 32px; height: 32px; padding: 20px; border-radius: 50%; fill: #fff; }
.fti-btn.no svg { background: var(--hang); }
.fti-btn.yes svg { background: var(--answer); }
.fti-btn:active svg { transform: translateY(1px); }

/* ---------- the picker ---------- */
.ftp { position: fixed; left: 0; right: 0; top: 0; height: var(--app-h); z-index: 30; display: flex; flex-direction: column; color: var(--letter); opacity: 0; transition: opacity .18s; overscroll-behavior: contain;
  background-color: var(--felt); background-image: radial-gradient(circle, var(--felt-groove) 1.3px, transparent 1.8px); background-size: 11px 11px; }
.ftp.in { opacity: 1; }
.ftp-top { flex: none; display: flex; align-items: center; gap: 8px; padding: calc(10px + env(safe-area-inset-top)) 16px 10px 8px; }
.ftp-back { flex: none; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--letter); display: grid; place-items: center; }
.ftp-back svg { width: 26px; height: 26px; fill: currentColor; }
.ftp-title { flex: 1; min-width: 0; }
.ftp-title .row2 { margin-top: 5px; }
.ftp-list { flex: 1; min-height: 0; overflow-y: auto; width: 100%; max-width: 640px; margin: 0 auto; padding: 8px 14px; }
.ftp-row { width: 100%; display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 0 6px; border: 0; border-bottom: 1px solid #f5f5f21f; background: none; color: var(--letter); font: inherit; text-align: left; }
.ftp-row:disabled { opacity: .45; }
.ftp-face { flex: none; width: 44px; height: 44px; border-radius: 50%; background: #e6e9f7; overflow: hidden; }
.ftp-face .mface, .ftp-face img, .ftp-face svg { display: block; width: 100%; height: 100%; }
.ftp-row.on .ftp-face { box-shadow: 0 0 0 3px var(--felt), 0 0 0 5px var(--talk); }
.ftp-name { flex: 1; min-width: 0; display: flex; flex-direction: column; font-weight: 700; font-size: 17px; overflow: hidden; }
.ftp-name small { font-weight: 400; font-size: 13px; opacity: .65; }
.ftp-check { flex: none; width: 28px; height: 28px; border-radius: 50%; border: 2px solid #f5f5f266; display: grid; place-items: center; }
.ftp-row.on .ftp-check { background: var(--talk); border-color: var(--talk); }
.ftp-check svg { width: 18px; height: 18px; fill: #fff; }
.ftp-empty { margin: 18px 6px; opacity: .7; font-size: 15px; }
.ft-add .ftp-name small { opacity: 1; color: var(--ink-2); }
.ftp-foot { flex: none; display: flex; justify-content: center; gap: 12px; padding: 14px 16px calc(16px + env(safe-area-inset-bottom)); }
.ftp-go { flex: 1; max-width: 240px; min-height: 54px; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 0 16px; border: 0; border-radius: 99px; background: var(--answer); color: #fff; font: 700 17px/1 var(--font); box-shadow: inset 0 -4px 0 #0000002e; }
.ftp-go svg { width: 22px; height: 22px; fill: currentColor; }
.ftp-go.audio { background: none; color: var(--letter); box-shadow: inset 0 0 0 2px var(--letter); }
.ftp-go:disabled { opacity: .4; }
.ftp-go:active:not(:disabled) { transform: translateY(1px); }

@media (prefers-reduced-motion: reduce) {
  .ft, .fti, .ftp, .ft-tile::after { transition: none; }
  .fti-wave { animation: none; transform: scale(1.18); opacity: .6; }
  .fti-wave.two { display: none; }
  .ft-tile.ringing .ft-face, .ft-rface { animation: none; }
}
