/*
  ChoreBoy's Phase 7b screens (DESIGN.md "Phase 7b"): the 👥 Friends view (web/friends.js, fr-
  classes), the 🔔 bell and notifications panel (web/notifications.js, nt- classes) and sharing one
  task (web/share.js, sh- classes: the editor's "👥 Share" picker and its dialog, the "👥 Celeste,
  Adam" tag and its who-sees list, "From Jared" / "Shared by Jared", the two filters).
  choreboy.css's tokens and components (panel, btn, chip, input, group-head, empty-state, link-btn,
  list-head), and upcoming.css's person colors (hh-c0 … hh-c7 set --hh) and avatar (.hh-av), so
  light and dark follow the device. Phones from 320 px; prefers-reduced-motion respected.

  WIRING: web/index.html loads it after upcoming.css: <link rel="stylesheet" href="social.css">.
*/

/* ---------- 🔔 the bell (top bar, before the 👤 chip) ---------- */

.nt-bell { position: relative; gap: .3rem; padding-left: .55rem; padding-right: .55rem; }
.nt-bell-ico { display: inline-block; line-height: 1; transform-origin: 50% 0; }
.nt-bell[aria-expanded="true"] { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; }
.nt-badge { min-width: 1.15rem; height: 1.15rem; padding: 0 .3rem; border-radius: 999px; background: var(--bad); color: #fff; font: 750 .68rem/1.15rem var(--font); text-align: center; font-variant-numeric: tabular-nums; }
.nt-bell.has-unread .nt-bell-ico { animation: nt-ring 1.2s ease-in-out 1; }
@keyframes nt-ring { 0%, 100% { transform: rotate(0); } 15% { transform: rotate(14deg); } 30% { transform: rotate(-12deg); } 45% { transform: rotate(8deg); } 60% { transform: rotate(-5deg); } 75% { transform: rotate(2deg); } }
body.logged-out #nt-bell, body.logged-out .nt-panel { display: none !important; }

/* ---------- 🔔 the panel: drops down under the bell ---------- */

.nt-panel {
  position: fixed; z-index: 345; /* over the editor (300) and the account menu (330); under Help (360) and the toast (400) */
  width: min(400px, calc(100vw - 16px));
  display: flex; flex-direction: column;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  overflow: hidden; animation: nt-in .16s ease-out;
}
@keyframes nt-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.nt-head { display: flex; align-items: center; gap: .35rem; padding: .6rem .55rem .6rem .95rem; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.nt-title { flex: 1; min-width: 0; margin: 0; font-size: 1rem; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nt-title:focus { outline: none; }
.nt-readall:disabled { visibility: hidden; }
.nt-x, .sh-x { flex-shrink: 0; width: 2rem; height: 2rem; display: grid; place-items: center; padding: 0; border: 0; border-radius: 999px; background: none; color: var(--text-2); font: 600 .95rem var(--font); cursor: pointer; }
.nt-x:hover, .sh-x:hover { background: var(--surface-2); color: var(--text); }
.nt-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.nt-foot { flex-shrink: 0; padding: .5rem .95rem .6rem; border-top: 1px solid var(--border); font-size: .84rem; }

.nt-list { list-style: none; margin: 0; padding: 0; }
.nt-item { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .65rem; align-items: start; padding: .7rem 1.6rem .7rem .85rem; border-top: 1px solid var(--border); }
.nt-item:first-child { border-top: 0; }
.nt-item.unread { background: color-mix(in srgb, var(--accent) 6%, var(--surface)); }
.nt-item:focus { outline: none; }
.nt-dot { position: absolute; top: 1.05rem; right: .7rem; width: .5rem; height: .5rem; border-radius: 50%; background: var(--accent); }
.nt-item > .hh-av { width: 2rem; height: 2rem; font-size: .88rem; }
.nt-ico { width: 2rem; height: 2rem; display: grid; place-items: center; flex-shrink: 0; border-radius: 50%; background: var(--surface-2); font-size: 1.05rem; line-height: 1; }
.nt-ico.level { background: var(--warn-soft); }
.nt-ico.remind { background: var(--info-soft); }
.nt-ico.tier-bronze { background: var(--warn-soft); }
.nt-ico.tier-silver { background: color-mix(in srgb, #98a2b3 24%, transparent); }
.nt-ico.tier-gold { background: color-mix(in srgb, #fdb022 32%, transparent); }
.nt-ico.tier-platinum { background: color-mix(in srgb, var(--purple) 22%, transparent); }
.nt-body { min-width: 0; display: flex; flex-direction: column; gap: .4rem; }
.nt-main { display: flex; flex-direction: column; gap: .15rem; min-width: 0; margin: -.2rem -.35rem; padding: .2rem .35rem; text-align: left; background: none; border: 0; border-radius: var(--radius-sm); font: 400 .9rem/1.4 var(--font); color: var(--text); }
button.nt-main { cursor: pointer; }
button.nt-main:hover { background: color-mix(in srgb, var(--text) 5%, transparent); }
.nt-text { overflow-wrap: anywhere; }
.nt-text b { font-weight: 650; }
.nt-when { font-size: .76rem; color: var(--text-3); font-variant-numeric: tabular-nums; }
.nt-xp { color: var(--gold); font-weight: 700; white-space: nowrap; }
.nt-acts { display: flex; flex-wrap: wrap; gap: .35rem; }
.nt-answer { margin: 0; font-size: .82rem; font-weight: 600; color: var(--good); }
.nt-err { margin: 0; font-size: .82rem; font-weight: 600; color: var(--bad); }
.nt-list-err { padding: .5rem .95rem; }
.nt-foot-note { margin: 0; padding: .55rem .95rem .7rem; border-top: 1px solid var(--border); }

.nt-state { padding: 1.6rem 1.2rem; text-align: center; color: var(--text-2); }
.nt-state p { margin: 0 0 .6rem; }
.nt-state p:last-child { margin-bottom: 0; }
.nt-empty b { color: var(--text); }
.nt-empty-ico { display: block; font-size: 2rem; line-height: 1; margin-bottom: .6rem; filter: grayscale(.3); }
.nt-loading, .fr-loading { display: flex; flex-direction: column; gap: .7rem; padding: 1.1rem 1rem; text-align: left; }
.nt-skel, .fr-skel { display: block; height: 2.6rem; border-radius: var(--radius); background: linear-gradient(90deg, var(--surface-2) 25%, var(--sunken) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: nt-shimmer 1.2s linear infinite; }
.nt-skel.short, .fr-skel.short { width: 60%; }
@keyframes nt-shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* ---------- 👥 Friends (the view) ---------- */

.fr-view { max-width: 760px; }
.fr-head { margin-bottom: 1rem; }
.fr-sr, .nt-sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.fr-add { margin: 0 0 1.2rem; }
.fr-add .panel-title { margin-bottom: .6rem; }
.fr-add-row { display: flex; gap: .5rem; align-items: center; }
.fr-add-row .input { flex: 1; }
.fr-add-note { margin: .45rem 0 0; }
.fr-msg { margin: .55rem 0 0; font-size: .88rem; font-weight: 600; }
.fr-msg:empty { display: none; }
.fr-msg.ok { color: var(--good); }
.fr-msg.bad { color: var(--bad); }
.fr-top-msg { margin: 0 0 1rem; }
.fr-sec { margin: 0 0 1.2rem; }
.fr-sec .group-head { margin-top: .2rem; }
.fr-people { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.fr-person { display: flex; align-items: center; flex-wrap: wrap; gap: .55rem .8rem; padding: .75rem .85rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.fr-person > .hh-av { width: 2.4rem; height: 2.4rem; font-size: 1rem; }
.fr-person.is-request { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); background: color-mix(in srgb, var(--accent) 6%, var(--surface)); }
.fr-person.is-sent { box-shadow: none; background: var(--surface-2); }
.fr-person.is-sent > .hh-av { opacity: .7; }
.fr-who { flex: 1; min-width: min(100%, 12rem); display: flex; flex-direction: column; gap: .3rem; overflow-wrap: anywhere; }
.fr-name { display: flex; flex-wrap: wrap; align-items: baseline; gap: .1rem .5rem; }
.fr-name b { font-weight: 650; }
.fr-email { font-size: .8rem; color: var(--text-3); }
.fr-sub { font-size: .8rem; color: var(--text-2); }
.fr-rels { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; }
.chip.fr-rel.hh { color: var(--accent-text); background: var(--accent-soft); border-color: transparent; }
.chip.fr-rel.one { color: var(--info); background: var(--info-soft); border-color: transparent; }
.fr-acts { display: flex; align-items: center; flex-wrap: wrap; gap: .3rem; margin-left: auto; }
.fr-ask { flex-basis: 100%; font-size: .84rem; font-weight: 600; color: var(--text-2); text-align: right; }
.fr-row-msg { flex-basis: 100%; margin: 0; padding-left: 3.2rem; font-size: .84rem; font-weight: 600; }
.fr-row-msg.ok { color: var(--good); }
.fr-row-msg.bad { color: var(--bad); }
.fr-empty { margin: 0 0 1.2rem; }
.fr-empty p { margin: 0 auto .5rem; max-width: 32rem; color: var(--text-2); }
.fr-empty p:last-child { margin-bottom: 0; }
.fr-empty b { color: var(--text); }
.fr-empty-ico { display: block; font-size: 2.2rem; line-height: 1; margin-bottom: .6rem; }
.fr-state p { margin: 0 0 .6rem; }
.fr-explain { padding: .8rem .95rem; border-radius: var(--radius); background: var(--surface-2); color: var(--text-2); font-size: .88rem; line-height: 1.5; }
.fr-explain p { margin: 0 0 .5rem; }
.fr-explain p:last-child { margin-bottom: 0; }
.fr-explain b { color: var(--text); }

/* ---------- 👥 tags on rows ---------- */

.sh-tag { display: inline-flex; max-width: 100%; }
.chip.sh-chip { cursor: pointer; color: var(--info); background: var(--info-soft); border-color: transparent; font-weight: 600; }
.chip.sh-chip:hover, .chip.sh-chip[aria-expanded="true"] { border-color: color-mix(in srgb, var(--info) 45%, transparent); }
/* The who-sees list: one floating element (share.js places it under, or over, the tag). */
.sh-pop { position: fixed; z-index: 380; width: max-content; max-width: min(18rem, calc(100vw - 16px)); padding: .6rem .7rem; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); font-size: .84rem; line-height: 1.4; animation: nt-in .12s ease-out; }
.sh-pop-h { display: block; margin: 0 0 .35rem; font-size: .72rem; font-weight: 750; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; }
.sh-pop-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .3rem; }
.sh-pop-list li { display: flex; align-items: center; gap: .45rem; min-width: 0; }
.sh-pop-name { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sh-how { flex-shrink: 0; padding: .02rem .45rem; border-radius: 999px; font-size: .72rem; font-weight: 650; }
.sh-how.hh { color: var(--accent-text); background: var(--accent-soft); }
.sh-how.one { color: var(--info); background: var(--info-soft); }
.sh-pop-foot { display: block; margin-top: .45rem; padding-top: .4rem; border-top: 1px solid var(--border); font-size: .76rem; color: var(--text-3); }

/* "From Jared" / "Shared by Jared" on someone else's task, in their color. */
.sh-from { display: inline-flex; align-items: center; gap: .28rem; max-width: 11rem; padding: .08rem .5rem .08rem .14rem; border-radius: 999px; background: color-mix(in srgb, var(--hh, var(--text-3)) 13%, transparent); color: var(--hh, var(--text-2)); font: 650 .74rem/1.3 var(--font); white-space: nowrap; vertical-align: .08em; }
.sh-from.one { background: transparent; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--hh, var(--text-3)) 45%, transparent); }
.sh-from .hh-av { width: 1.05rem; height: 1.05rem; font-size: .6rem; }
.sh-from-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* The two filters: "👥 Shared by me" · "📨 Shared with me". */
.sh-filters { display: inline-flex; flex-wrap: wrap; gap: .3rem; }
.chip.sh-filter { font-size: .8rem; }
.chip.sh-filter.on { color: var(--accent-text); background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }

/* ---------- 👥 the editor's picker ---------- */

.sh-picker { min-width: 0; }
.sh-note { margin: .2rem 0 .6rem; padding: .5rem .7rem; border-radius: var(--radius); background: var(--surface-2); color: var(--text-2); font-size: .86rem; }
.sh-note.priv { background: var(--warn-soft); color: var(--text); }
.sh-loading { margin: .3rem 0; }
.sh-find { margin: 0 0 .5rem; }
.sh-friends { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .3rem; max-height: 17rem; overflow-y: auto; overscroll-behavior: contain; }
.sh-friend-lab { display: flex; align-items: center; gap: .6rem; padding: .45rem .6rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); cursor: pointer; min-width: 0; }
.sh-friend-lab:hover { border-color: var(--accent); }
.sh-friend-lab:has(input:checked) { border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); background: color-mix(in srgb, var(--accent) 6%, var(--surface)); }
.sh-friend-lab input { width: 1.1rem; height: 1.1rem; margin: 0; flex-shrink: 0; }
.sh-friend-lab .hh-av { width: 1.7rem; height: 1.7rem; font-size: .78rem; }
.sh-friend.is-household .sh-friend-lab { cursor: default; background: var(--surface-2); border-style: dashed; }
.sh-friend.is-household .sh-friend-lab:hover { border-color: var(--border); }
.sh-friend-who { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: .1rem .5rem; overflow-wrap: anywhere; font-size: .9rem; }
.sh-friend-who b { font-weight: 600; }
.sh-email { font-size: .78rem; color: var(--text-3); }
.chip.sh-hh-chip { color: var(--accent-text); background: var(--accent-soft); border-color: transparent; white-space: normal; }
.sh-none { padding: .4rem .2rem; }
.sh-msg { margin: .45rem 0 0; font-size: .86rem; font-weight: 600; color: var(--bad); }
.sh-msg.ok { color: var(--good); }
.sh-msg:empty { display: none; }
.sh-explain { margin: .5rem 0 0; }
.sh-empty { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem .8rem; padding: .7rem .8rem; border: 1px dashed var(--border-strong); border-radius: var(--radius); color: var(--text-2); font-size: .9rem; }
.sh-empty p { margin: 0; }
.sh-empty.bad { border-color: color-mix(in srgb, var(--bad) 40%, transparent); color: var(--bad); }

/* ---------- 👥 the row action's dialog ---------- */

.sh-overlay { position: fixed; inset: 0; z-index: 320; display: flex; align-items: center; justify-content: center; padding: 1rem; background: rgba(16, 24, 40, .45); }
.sh-dialog { width: min(480px, 100%); max-height: calc(100vh - 2rem); overflow-y: auto; overscroll-behavior: contain; box-shadow: var(--shadow-lg); animation: nt-in .16s ease-out; }
.sh-dialog-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .2rem; }
.sh-dialog-head .panel-title { flex: 1; margin: 0; }
.sh-dialog-task { margin: 0 0 .7rem; font-weight: 600; color: var(--text-2); overflow-wrap: anywhere; }
.sh-dialog-foot { margin-top: 1rem; }
body.sh-dialog-open { overflow: hidden; }

/* ---------- small screens ---------- */

@media (max-width: 600px) {
  .nt-bell { padding-left: .45rem; padding-right: .45rem; }
  .nt-panel { width: auto; }
  .nt-item { padding-left: .75rem; }
  .fr-add-row { flex-wrap: wrap; }
  .fr-add-row .input { flex-basis: 100%; font-size: 16px; } /* smaller and iPhones zoom on focus */
  .fr-add-row .btn { flex: 1 1 auto; }
  .fr-person { padding: .65rem .7rem; }
  .fr-acts { margin-left: 3.2rem; }
  .fr-ask { text-align: left; }
  .sh-overlay { align-items: flex-end; padding: 0; }
  .sh-dialog { width: 100%; max-height: 92vh; border-radius: var(--radius-lg) var(--radius-lg) 0 0; padding-bottom: calc(1.1rem + env(safe-area-inset-bottom)); }
  .sh-dialog-foot .btn { flex: 1 1 auto; }
}
@media (max-width: 380px) {
  .fr-acts { margin-left: 0; width: 100%; }
  .fr-row-msg { padding-left: 0; }
  .nt-head { padding-left: .75rem; }
}

@media (prefers-reduced-motion: reduce) {
  .nt-panel, .sh-pop, .sh-dialog { animation: none; }
  .nt-bell.has-unread .nt-bell-ico { animation: none; }
  .nt-skel, .fr-skel { animation: none; }
}
@media print {
  #nt-bell, .nt-panel, .sh-pop, .sh-overlay { display: none !important; }
}

/* Settings → 🔔 Notifications: the kinds you can turn off. */
.nt-set { border: 0; margin: .6rem 0 0; padding: 0; min-width: 0; }
.nt-set legend { padding: 0; }
.nt-set .check.block { margin: .45rem 0; }

/* The 🔔 bell needs room in the top bar between phone and desktop widths: the level's title goes first. */
@media (max-width: 860px) and (min-width: 601px) {
  .lv-title { display: none; }
}
/* (and on the narrowest phones, the chance of rain) */
@media (max-width: 380px) {
  .wx-pop { display: none; }
}
