/* ============================================================
   Features bento (index.html #features): a 6-column grid of flat grey tiles, each a small drawn conversation or card
   above its title. Loaded after landing.css, group-bg-demo.css and polls-demo.css, which it builds on (poll balloon, Memoji
   orbit, chat-background layers) and overrides inside .feature-grid.bento.
   Motion is transform and opacity only; js/features-bento.js pauses it while a tile is off screen. Reduced motion: still,
   complete frames. Nothing here uses backdrop-filter or mix-blend-mode.
   ============================================================ */
.arc-concept .imsg .feature-grid.bento {
  --fb-tile: var(--tile); --fb-panel: var(--tile-panel); --fb-bubin: #e9e9eb; --fb-chip: #eff0f3;
  --fb-ink: #1d1d1f; --fb-muted: #6e6e73; --fb-blue: #0a84ff; --fb-green: #2fb457;
  --fb-shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 20px 50px -30px rgba(20, 30, 60, .30);
  display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 16px;
  border: 0; background: none; overflow: visible; border-radius: 0;
}
[data-theme="dark"] .arc-concept .imsg .feature-grid.bento {
  --fb-bubin: #454951; --fb-chip: #3f434b;
  --fb-ink: #f5f5f7; --fb-muted: #a1a1a6;
  --fb-shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 20px 40px -24px rgba(0, 0, 0, .7);
}

/* ---- the tile ---- */
.arc-concept .imsg .feature-grid.bento > .feature {
  container: fb / inline-size;
  display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: 18px;
  min-height: 380px; padding: 28px; position: relative; overflow: hidden;
  border: 0; border-radius: 28px; background: var(--fb-tile); box-shadow: none; color: var(--fb-ink);
}
.arc-concept .imsg .feature-grid.bento > .f-2 { grid-column: span 2; }
.arc-concept .imsg .feature-grid.bento > .f-3 { grid-column: span 3; }
.arc-concept .imsg .feature-grid.bento > .f-4 { grid-column: span 4; }
.arc-concept .imsg .feature-grid.bento > .f-tall { grid-row: span 2; }
.arc-concept .imsg .feature-grid.bento .feature .feature-media {
  /* the em on every drawing below comes from this size, off the tile's own width */
  font-size: clamp(13px, 6cqw, 19px);
  display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; width: 100%; min-height: 0; aspect-ratio: auto;
  background: none; padding: 0; overflow: visible; color: var(--fb-ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased; text-align: left; letter-spacing: -.01em;
}
.arc-concept .imsg .feature-grid.bento .feature.f-3 .feature-media { font-size: clamp(13px, 3.5cqw, 19px); }
.arc-concept .imsg .feature-grid.bento .feature.f-4 .feature-media { font-size: clamp(12px, 2.25cqw, 16px); }
.arc-concept .imsg .feature-grid.bento .feature .feature-body { padding: 0; }
.arc-concept .imsg .feature-grid.bento .feature h3 {
  margin: 0; font-size: 22px; font-weight: 400; letter-spacing: -.025em; line-height: 1.2; color: var(--fb-ink);
  position: static;   /* the title's link stretches over the whole tile, so the heading must not be its containing block (js/text-select.js makes text blocks position: relative) */
}

/* inner panels */
.fb-panel { background: var(--fb-panel); border-radius: 1.15em; box-shadow: var(--fb-shadow); }

/* iMessage bubbles (no hook tails: one squared corner instead) */
.fb-b {
  position: relative; max-width: 88%; padding: .5em .85em; border-radius: 1.2em;
  font-size: .93em; line-height: 1.3; background: var(--fb-bubin); color: var(--fb-ink);
}
.fb-b.is-in { align-self: flex-start; border-bottom-left-radius: .4em; }
.fb-b.is-out { align-self: flex-end; background: var(--fb-blue); color: #fff; border-bottom-right-radius: .4em; }

/* ---- AI replies ---- */
.fb-persona { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75em; width: 100%; max-width: 46em; }
@container fb (min-width: 560px) { .fb-persona { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.fb-pcard {
  position: relative; display: grid; grid-template-columns: 2.4em minmax(0, 1fr); column-gap: .75em; row-gap: .15em;
  align-content: start; min-width: 0; padding: 1em; border-radius: 1.1em; background: var(--fb-panel); box-shadow: var(--fb-shadow);
}
/* the selection ring: opacity only, so cycling it costs the compositor nothing */
.fb-pcard::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  box-shadow: inset 0 0 0 2px var(--fb-blue); opacity: 0;
}
.fb-pcard.on::after { opacity: 1; }
.arc-concept .imsg .fb-pcard .pp-icon {
  grid-row: span 2; align-self: start; width: 2.4em; height: 2.4em; border-radius: .7em;
  background: color-mix(in srgb, var(--fb-blue) 13%, var(--fb-panel)); color: var(--fb-blue);
}
.arc-concept .imsg .fb-pcard .pp-icon svg { width: 1.35em; height: 1.35em; }
.fb-pname { align-self: end; font-size: .93em; font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; }
.fb-pdesc { grid-column: 2; font-size: .86em; line-height: 1.35; color: var(--fb-muted); }
@media (prefers-reduced-motion: no-preference) {
  /* six cards, 2.2 s each; Friend (index 3) is lit first, so the delay is (i - 3) steps */
  .fb-pcard { animation: fb-lift 13.2s ease-in-out infinite; animation-delay: calc((var(--i) - 3) * 2.2s); }
  .fb-pcard::after { animation: fb-ring 13.2s ease-in-out infinite; animation-delay: calc((var(--i) - 3) * 2.2s); }
}
@keyframes fb-ring { 0%, 14% { opacity: 1; } 18%, 100% { opacity: 0; } }
@keyframes fb-lift { 0%, 14% { transform: translateY(-2px); } 18%, 100% { transform: none; } }

/* ---- Your name and photo ---- */
.fb-contact { width: min(100%, 17.5em); padding: 1.6em 1.3em 1.4em; display: grid; justify-items: center; gap: .65em; text-align: center; }
.fb-contact img { width: 4.75em; height: 4.75em; border-radius: 1.1em; display: block; box-shadow: 0 6px 16px -6px rgba(0, 0, 0, .3); }
.fb-contact b { font-size: 1.1em; font-weight: 600; }
.fb-contact-line { max-width: 24ch; font-size: .8em; line-height: 1.4; color: var(--fb-muted); }
.fb-contact-btn { margin-top: .3em; padding: .5em 1.7em; border-radius: 999px; background: var(--fb-blue); color: #fff; font-size: .85em; font-weight: 500; }

/* ---- Polls: the real poll balloon (js/polls-demo.js, counts mode), white, with bars that fill ---- */
.arc-concept .imsg .poll-demo.fb-poll {
  --poll-gray: var(--fb-panel); --poll-blue: var(--fb-blue);
  width: min(100%, 17.5em); margin: 0 0 0 .4em; padding: 1em 1em 1.05em; color: var(--fb-ink); font-size: 1em;
}
.fb-poll .poll-art { filter: drop-shadow(0 1px 1.5px rgba(0, 0, 0, .06)) drop-shadow(0 14px 22px rgba(20, 30, 60, .10)); }
.fb-poll .poll-art path { fill: var(--fb-panel); }
.fb-poll .poll-q { font-size: 1em; line-height: 1.3; }
.fb-poll .poll-sub { margin-top: .1em; font-size: .78em; line-height: 1.3; color: var(--fb-muted); }
.fb-poll .poll-opts { gap: .5em; margin-top: .8em; }
.fb-poll .poll-opt {
  position: relative; overflow: hidden; width: 100%; height: auto; padding: .55em .8em; border-radius: .7em;
  background: var(--fb-chip); color: var(--fb-ink); font-size: .87em; font-weight: 500; transition: none;
}
.fb-poll .poll-opt.is-voted { background: var(--fb-chip); color: var(--fb-ink); }
.fb-poll .poll-opt::before {
  content: ""; position: absolute; inset: 0; background: color-mix(in srgb, var(--fb-blue) 26%, transparent);
  transform-origin: left center; transform: scaleX(var(--share, 0)); transition: transform .8s cubic-bezier(.2, .8, .2, 1);
}
.fb-poll .poll-label, .fb-poll .poll-tally { position: relative; }
.fb-poll .poll-tally { font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) { .fb-poll .poll-opt::before { transition: none; } }

/* ---- Reactions ---- */
.fb-react { width: min(100%, 17em); display: flex; flex-direction: column; }
.fb-react .fb-b { max-width: 88%; }
/* the badges are css/tapback.css, landed and let go by js/features-bento.js. The size is twice this tile's text, so the 1.6em gap is .8 of it. */
.fb-react { --tb-size: clamp(26px, 12cqw, 38px); --tb-ring: var(--fb-panel); --tb-theirs: var(--fb-bubin); --tb-room: calc((38 / 34 - .8) * var(--tb-size)); gap: calc(.8 * var(--tb-size)); padding: 1.2em; }

/* ---- Photos and voice memos ---- */
.fb-media { width: min(100%, 21em); display: grid; gap: .5em; justify-items: stretch; }
.fb-from { margin-left: .8em; font-size: .75em; color: var(--fb-muted); }
.fb-photo { display: block; width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 1.2em; }
.fb-media .fb-b.is-in { justify-self: start; }
.fb-voice {
  justify-self: end; display: flex; align-items: center; gap: .65em; padding: .6em .9em; border-radius: 1.3em;
  border-bottom-right-radius: .4em; background: var(--fb-blue); color: #fff;
}
.fb-voice svg { width: .9em; height: .9em; flex: none; }
.fb-voice small { font-size: .8em; opacity: .85; font-variant-numeric: tabular-nums; }
.fb-wave { display: flex; align-items: center; gap: 2px; height: 1.4em; }
.fb-wave i { width: 3px; height: var(--wh); border-radius: 2px; background: #fff; }
@media (prefers-reduced-motion: no-preference) {
  .fb-wave i { animation: fb-wv 1.1s ease-in-out infinite; animation-delay: var(--d); }
}
@keyframes fb-wv { 50% { transform: scaleY(.35); } }

/* ---- Chat backgrounds: the four real presets (.cbg-layer fades in css/group-bg-demo.css) behind two bubbles ---- */
.fb-cbg {
  position: relative; isolation: isolate; overflow: hidden; width: min(100%, 22em); height: 15em; padding: 1.1em 1.2em;
  display: flex; flex-direction: column; justify-content: flex-end; gap: .6em; border-radius: 1.4em; background: #cfd6e6; box-shadow: var(--fb-shadow);
}
.fb-cbg .fb-b { z-index: 1; }
.fb-cbg .fb-b.is-in { background: rgba(255, 255, 255, .86); color: #111; }   /* a flat tint, not a blur: the card sits over moving images */

/* ---- Group chats: the real Memoji orbit (css/group-bg-demo.css), dashed rings, a people hub ---- */
.arc-concept .imsg .feature-grid.bento .group-demo { width: min(100%, 19em); height: auto; max-width: none; aspect-ratio: 1; }
.arc-concept .imsg .feature-grid.bento .grp-orbit { border: 1px dashed color-mix(in srgb, var(--fb-ink) 22%, transparent); }
.arc-concept .imsg .feature-grid.bento .grp-slot img {
  background: linear-gradient(180deg, #eeeef2 0%, #dcdce2 100%); box-shadow: 0 0 0 2px var(--fb-tile), 0 2px 8px rgba(30, 34, 48, .12);
}
.arc-concept .imsg .feature-grid.bento .grp-hub { background: var(--fb-panel); color: var(--fb-blue); box-shadow: var(--fb-shadow); }
.arc-concept .imsg .feature-grid.bento .grp-hub svg { width: 52%; height: 52%; fill: currentColor; }

/* ---- Threads ---- */
.fb-threads { width: min(100%, 16.5em); display: grid; gap: .3em; }
.fb-threads > .fb-b { justify-self: start; }
.fb-reply { position: relative; display: grid; grid-template-columns: 1.2em minmax(0, 1fr); margin-left: .9em; }
.fb-reply::before {
  content: ""; width: .8em; height: 1.3em; border-left: 2px solid color-mix(in srgb, var(--fb-ink) 20%, transparent);
  border-bottom: 2px solid color-mix(in srgb, var(--fb-ink) 20%, transparent); border-bottom-left-radius: .7em;
}
.fb-reply .fb-b { justify-self: start; border-bottom-right-radius: 1.2em; border-bottom-left-radius: .4em; }
.fb-replies { margin: .2em 0 0 .9em; color: var(--fb-blue); font-size: .8em; }

/* ---- CRM integrations ---- */
.fb-crm { display: grid; gap: .65em; width: min(100%, 19em); }
.fb-crm-row {
  display: grid; grid-template-columns: 2.4em minmax(0, 1fr) auto; align-items: center; gap: .8em; padding: .75em .9em;
  border-radius: 1em; background: var(--fb-panel); box-shadow: var(--fb-shadow);
}
.fb-crm-ico { width: 2.4em; height: 2.4em; border-radius: .65em; display: grid; place-items: center; background: #fff; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .06); }
.fb-crm-ico svg { width: 1.4em; height: 1.4em; display: block; }
.fb-crm-name { font-size: .95em; font-weight: 600; }
.fb-crm-sync { display: inline-flex; align-items: center; gap: .4em; font-size: .78em; color: var(--fb-muted); }
.fb-crm-sync i { width: .55em; height: .55em; border-radius: 50%; background: var(--fb-green); }
@media (prefers-reduced-motion: no-preference) { .fb-crm-sync i { animation: fb-blink 2.4s ease-in-out infinite; } }
@keyframes fb-blink { 50% { opacity: .35; } }

/* ---- Off screen / hidden tab: every animation in the tile holds still ---- */
.feature-grid.bento .feature.is-offscreen *, .feature-grid.bento .feature.is-offscreen *::before, .feature-grid.bento .feature.is-offscreen *::after,
.feature-grid.bento.is-tab-hidden *, .feature-grid.bento.is-tab-hidden *::before, .feature-grid.bento.is-tab-hidden *::after { animation-play-state: paused !important; }

/* ---- Narrow: one column ---- */
@media (max-width: 900px) {
  .arc-concept .imsg .feature-grid.bento { grid-template-columns: 1fr; }
  .arc-concept .imsg .feature-grid.bento > .feature { grid-column: auto; grid-row: auto; min-height: 0; padding: 26px 22px 22px; }
  .arc-concept .imsg .feature-grid.bento .feature .feature-media { padding-block: 6px 10px; }
  .arc-concept .imsg .feature-grid.bento .feature.f-4 .feature-media { font-size: clamp(12px, 3.4cqw, 15px); }
  .arc-concept .imsg .feature-grid.bento .feature.f-3 .feature-media { font-size: clamp(13px, 4.2cqw, 17px); }
}

/* ---- tile links (whole tile is one link: the title's anchor stretches over it, the heading stays a heading) ----
   Press, spring and focus come from "Button motion" in landing.css (tokens --btn-*), at the wide scale. Hover (fine pointers
   only) lifts the tile 4px, tints it and slides the arrow chip; keyboard focus rings the tile. Transform, opacity and colours
   only. Reduced motion keeps the tint and the chip's colour change and drops the lift, the press scale and the slide. */
.arc-concept .imsg .feature-grid.bento { --fb-hover: rgba(20, 30, 60, .045); }
[data-theme="dark"] .arc-concept .imsg .feature-grid.bento { --fb-hover: rgba(255, 255, 255, .06); }
.arc-concept .imsg .feature-grid.bento > .feature { transition: transform var(--btn-release) var(--btn-spring); }
.arc-concept .imsg .feature-grid.bento > .feature::before {
  content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: var(--fb-hover); opacity: 0; transition: opacity var(--btn-colour) var(--btn-ease-colour);
}
.arc-concept .imsg .feature-grid.bento .fb-link { color: inherit; text-decoration: none; -webkit-tap-highlight-color: transparent; }
.arc-concept .imsg .feature-grid.bento .fb-link::after { content: ""; position: absolute; inset: 0; z-index: 2; border-radius: 28px; }
.arc-concept .imsg .feature-grid.bento .fb-link:focus-visible { outline: none; }
.arc-concept .imsg .feature-grid.bento .fb-link:focus-visible::after { outline: 2px solid var(--btn-ring); outline-offset: -4px; }
/* the arrow is a small round button, so the tile reads as pressable before it is hovered */
.arc-concept .imsg .feature-grid.bento .fb-arrow {
  display: inline-block; box-sizing: border-box; width: 28px; height: 28px; padding: 7px; vertical-align: -7px; margin-left: 10px;
  border-radius: 50%; color: var(--fb-muted); background: var(--btn-wash);
  transition: transform var(--btn-release) var(--btn-spring), color var(--btn-colour) var(--btn-ease-colour), background-color var(--btn-colour) var(--btn-ease-colour);
}
.arc-concept .imsg .feature-grid.bento > .feature:focus-within .fb-arrow { color: var(--fb-ink); background: var(--btn-wash-strong); }
@media (hover: hover) and (pointer: fine) {
  .arc-concept .imsg .feature-grid.bento > .feature:hover { transform: translateY(-4px); transition-duration: .24s; transition-timing-function: var(--btn-ease-colour); }
  .arc-concept .imsg .feature-grid.bento > .feature:hover::before { opacity: 1; }
  .arc-concept .imsg .feature-grid.bento > .feature:hover .fb-arrow { color: var(--fb-ink); background: var(--btn-wash-strong); transform: translateX(3px); }
}
.arc-concept .imsg .feature-grid.bento > .feature:active { transform: scale(var(--btn-press-scale-wide)); transition-duration: var(--btn-press-in); transition-timing-function: var(--btn-ease-press); }
.arc-concept .imsg .feature-grid.bento > .feature:active::before { opacity: 1; }
.arc-concept .imsg .feature-grid.bento > .feature:active .fb-arrow { color: var(--fb-ink); background: var(--btn-wash-strong); }
@media (prefers-reduced-motion: reduce) {
  .arc-concept .imsg .feature-grid.bento > .feature,
  .arc-concept .imsg .feature-grid.bento > .feature:hover,
  .arc-concept .imsg .feature-grid.bento > .feature:active { transform: none; transition: none; }
  .arc-concept .imsg .feature-grid.bento > .feature::before { transition: opacity .16s ease; }
  .arc-concept .imsg .feature-grid.bento .fb-arrow,
  .arc-concept .imsg .feature-grid.bento > .feature:hover .fb-arrow { transform: none; transition: color .16s ease, background-color .16s ease; }
}
}
