/* Friends (/shared/friends.js): the button on the home page, the cards it opens - your friends, one friend, Add a
   friend, a friend's link, Invite friends, Challenge a friend - and the banner an invite or a challenge arrives as.
   Global, unscoped: the cards open on whichever screen is up. The cards themselves are /shared/sheet.css's, their
   tabs /shared/tabs.css's, and the buttons theme.css's. What the lobby, solo mode and Daily Jam add for friends is in
   their own stylesheets. */

/* ---------- The button on the home page ---------- */

/* In the corner across from Account, and made like it: a glass pill with a white circle */
.home-friends {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top, 0px));
  left: calc(12px + env(safe-area-inset-left, 0px));
  z-index: 10;
}
.friends-btn {
  appearance: none;
  position: relative;
  height: 44px;
  padding: 0 14px 0 9px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--glass-line);
  border-radius: 999px;
  background: var(--glass);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background 0.15s ease;
}
@media (hover: hover) {
  .friends-btn:hover { background: rgba(255, 255, 255, 0.2); }
}
.friends-btn:is(:active, .is-pressed) { scale: 0.96; }
.friends-btn > i {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--chip);
  color: var(--chip-ink);
  font-style: normal;
  font-size: 14px;
  line-height: 1;
}
/* How many friends are online */
.friends-count {
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: var(--go-light);
  color: #064e3b;
  font-weight: 800;
  font-size: 12px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.friends-count:empty { display: none; }
/* Something's waiting: a request, an invite, a challenge */
.friends-btn.has-news::after {
  content: "";
  position: absolute;
  top: -2px;
  right: -2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--jam);
  box-shadow: 0 0 0 2px var(--bg-1);
}
/* Phones narrower than most: just the circle and the count, so it never reaches Account */
@media (max-width: 389px) {
  .friends-label { display: none; }
  .friends-btn { padding-right: 9px; }
}


/* ---------- What the cards share ---------- */

/* A person's picture: their photo, or their initial on their color (/shared/players.js), any size - with a green dot
   on its corner while they're online, ringed in what it sits on (--ring) */
.friend-face {
  position: relative;
  flex: none;
  width: var(--face, 36px);
  height: var(--face, 36px);
  display: grid;
}
.friend-face > .avatar, .friend-face > img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  font-size: calc(var(--face, 36px) * 0.42);
}
.friend-face > img { object-fit: cover; background: var(--field); }
.friend-face.is-online::after {
  content: "";
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: max(11px, 28%);
  height: max(11px, 28%);
  border-radius: 50%;
  background: var(--go-light);
  box-shadow: 0 0 0 2px var(--ring, var(--field));
}

.friends-label-line {
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.friends-rows {
  margin: -8px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 6px;
}
/* A row: a person, what there is to say about them, and what can be done - the whole row a button when a tap on it
   opens something */
.friend-row {
  appearance: none;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  margin: 0;
  padding: 8px 12px 8px 10px;
  border: 0;
  border-radius: 12px;
  background: var(--field);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  font-size: 15px;
  text-align: left;
}
button.friend-row { cursor: pointer; }
button.friend-row:is(:active, .is-pressed) { background: var(--field-line); scale: none; }
@media (hover: hover) {
  button.friend-row:hover { background: var(--row-hover); }
}
.friend-who {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1px;
}
/* A name on one line, cut short if it must be; the line under it on as many as it takes (what an invite is to) */
.friend-who > b, .friend-who > small { overflow-wrap: anywhere; }
.friend-who > b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.friends-page .friend-row:has(.friend-acts) .friend-who > b { white-space: normal; }
.friend-who > small { font-weight: 500; font-size: 13px; color: var(--ink-soft); }
.friend-who > small.is-live { color: var(--good-ink); font-weight: 600; }
.friend-chev { flex: none; color: var(--ink-muted); font-size: 22px; line-height: 1; }
.friend-acts { flex: none; display: flex; gap: 6px; }
/* A button on a row: small to look at, the row's height to a finger */
.btn.btn-row { min-height: 40px; padding: 4px 14px; font-size: 14px; border-radius: 10px; flex: none; }
.btn.btn-row::after { content: ""; position: absolute; inset: -8px -2px; }
.btn.btn-done, .btn.btn-done:disabled { background: var(--good-bg); color: var(--good-ink); border-color: transparent; opacity: 1; box-shadow: none; }

.friends-note { margin: 0; font-size: 15px; line-height: 1.45; color: var(--ink-muted); }
.friends-fine { margin: 0; font-size: 13px; line-height: 1.4; color: var(--ink-muted); }
.friends-empty {
  margin: 0;
  padding: 18px 8px;
  display: grid;
  justify-items: center;
  gap: 12px;
  text-align: center;
  font-weight: 600;
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink-muted);
}
.friends-rule { height: 1px; margin: 0; border: 0; background: var(--field-line); }
.friends-block { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.friends-block > .friends-rows { margin-top: 0; }
.friends-status {
  flex: none;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--field-line);
  color: var(--ink-soft);
  font-weight: 700;
  font-size: 12px;
  line-height: 1.4;
  white-space: nowrap;
}
.friends-status.is-live { background: var(--good-bg); color: var(--good-ink); }


/* ---------- Your friends ---------- */

/* Friends | Requests: the leaderboard's switch (board.css), made again here since the card opens on any screen */
.friends-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  --tabs-gap: 2px;
  padding: 3px;
  border-radius: 12px;
  background: var(--field);
}
.friends-tabs button {
  appearance: none;
  height: 34px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--ink-muted);
  font: inherit;
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
  cursor: pointer;
}
.friends-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: #be185d;
  color: #fff;
  font-weight: 800;
  font-size: 11px;
  line-height: 1;
}
.friends-badge:empty { display: none; }
.friends-stage { flex: 1 1 auto; min-height: 0; }
.friends-page.sheet-body { padding-bottom: 16px; }
/* Add a friend, along the bottom of the card whichever tab is up */
.friends-foot {
  flex: none;
  display: grid;
  padding: 12px var(--sheet-side) max(16px, calc(env(safe-area-inset-bottom, 0px) + 10px));
  border-top: 1px solid var(--field-line);
}


/* ---------- One friend, a friend's link, an invite: the cards with someone in the middle ---------- */

.friend-card { text-align: center; }
.friend-card > .sheet-body { justify-items: center; gap: 12px; padding-top: 14px; }
.friend-card h2 { margin: 0; font-weight: 800; font-size: 22px; line-height: 1.2; overflow-wrap: anywhere; }
.friend-card .friend-face { --ring: var(--surface); }
.friend-card .friends-note { text-wrap: balance; }
.friend-stats {
  width: 100%;
  margin: 4px 0 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.friend-stats > div {
  padding: 10px 6px;
  display: flex;
  flex-direction: column-reverse;
  gap: 4px;
  border-radius: 12px;
  background: var(--field);
}
.friend-stats dt { font-weight: 600; font-size: 12px; color: var(--ink-soft); }
.friend-stats dd { margin: 0; font-weight: 800; font-size: 20px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.friend-actions { width: 100%; margin-top: 4px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.friend-actions.is-pair { grid-template-columns: repeat(2, minmax(0, 1fr)); }
/* Not now, Remove friend: quiet, under the buttons (as the reminders box's Not now - theme.css) */
.friends-quiet {
  position: relative;
  justify-self: center;
  padding: 6px 8px;
  border: 0;
  background: none;
  color: var(--ink-muted);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.friends-quiet::after { content: ""; position: absolute; inset: -8px -4px; }
.friends-quiet:is(:active, .is-pressed) { scale: 0.97; opacity: 0.6; }
.friends-quiet.is-sure { color: var(--bad-ink); }


/* ---------- Add a friend, Challenge a friend ---------- */

/* Your link, with Copy beside it */
.friends-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 50px;
  padding: 0 6px 0 14px;
  border: 2px solid var(--field-line);
  border-radius: 12px;
  background: var(--field);
  font-weight: 600;
  font-size: 15px;
}
.friends-link > span {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  -webkit-user-select: all;
  user-select: all;
}
/* What a challenge says, as it'll be sent */
.friends-quote {
  margin: 0;
  padding: 12px 14px;
  display: grid;
  gap: 4px;
  border-radius: 12px;
  background: var(--field);
  font-weight: 700;
  font-size: 15px;
  line-height: 1.35;
}
.friends-quote > small { font-weight: 500; font-size: 13px; color: var(--ink-soft); overflow-wrap: anywhere; }
/* A friend to tap: their face, their name, and a plus - or Sent */
.friends-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.friends-chip {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  max-width: 100%;
  padding: 0 14px 0 8px;
  border: 2px solid var(--field-line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
  cursor: pointer;
  --face: 28px;
  --ring: var(--surface);
}
.friends-chip > span:not(.friend-face) { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.friends-chip > i { font-style: normal; font-weight: 800; color: var(--jam-deep); }
.friends-chip.is-sent, .friends-chip.is-sent:disabled { border-color: transparent; background: var(--good-bg); color: var(--good-ink); --ring: var(--good-bg); cursor: default; opacity: 1; }
.friends-chip:disabled:not(.is-sent) { opacity: 0.6; cursor: progress; }


/* ---------- The banner: an invite, a challenge, news ---------- */

/* Where the game's toasts go (--toast-top, set as it comes up - /shared/friends.js), and made like the dark one
   (theme.css): who it's from, what it is, the one thing to do about it, and a × */
.friends-banner {
  position: fixed;
  left: 50%;
  top: calc(var(--toast-top, 64px) + env(safe-area-inset-top, 0px));
  z-index: 1001;
  width: min(94vw, 440px);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 6px 10px 12px;
  border: 1px solid var(--glass-line);
  border-radius: 14px;
  background: rgba(30, 27, 46, 0.97);
  color: #fff;
  font-family: var(--font);
  font-weight: 600;
  font-size: 15px;
  line-height: 1.3;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
  translate: -50% 0;
  touch-action: none;
  --ring: #1e1b2e;
}
.friends-banner-text { flex: 1; min-width: 0; display: grid; gap: 1px; }
.friends-banner-text > b { font-weight: 600; overflow-wrap: anywhere; }
.friends-banner-text > small { font-weight: 500; font-size: 13px; color: var(--on-dark-muted); }
.friends-banner .btn { flex: none; }
.friends-banner-close {
  appearance: none;
  flex: none;
  width: 32px;
  height: 44px;
  border: 0;
  background: transparent;
  color: var(--on-dark-muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.friends-banner-close:is(:active, .is-pressed) { scale: 0.92; }
/* Over a card (a modal dialog is above everything else on the page): it rides on the card's own layer */
dialog.sheet > .friends-banner { position: fixed; }

/* A switch row in the account box (Appear offline), as the reminders box has them (theme.css) */
.account-switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 56px;
  padding: 8px 0;
  border-top: 1px solid var(--field-line);
  text-align: left;
  cursor: pointer;
}
.account-switch b { display: block; font-weight: 700; }
.account-switch small { display: block; margin-top: 2px; font-size: 13px; line-height: 1.3; color: var(--ink-muted); }
